prob_desc_description stringlengths 63 3.8k | prob_desc_output_spec stringlengths 17 1.47k β | lang_cluster stringclasses 2 values | src_uid stringlengths 32 32 | code_uid stringlengths 32 32 | lang stringclasses 7 values | prob_desc_output_to stringclasses 3 values | prob_desc_memory_limit stringclasses 19 values | file_name stringclasses 111 values | tags listlengths 0 11 | prob_desc_created_at stringlengths 10 10 | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_notes stringlengths 4 3k β | exec_outcome stringclasses 1 value | difficulty int64 -1 3.5k β | prob_desc_input_from stringclasses 3 values | prob_desc_time_limit stringclasses 27 values | prob_desc_input_spec stringlengths 28 2.42k β | prob_desc_sample_outputs stringlengths 2 796 | source_code stringlengths 42 65.5k | hidden_unit_tests stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 0671d4334536ce669349e3e47ca9b2c7 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int t,d;
scanf("%d",&t);
while(t--)
{
int h,m;
scanf("%d%d",&h,&m);
d=1440-((60*h)+m);
printf("%d\n",d);
}
return 0;
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 04f854322504383460edf9f42e901f34 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h> /*primer raboty 12:10:00 + 80 -> 12:11:10*/
struct Time
{
int hour;
int minute;
};
int main()
{
int n, i;
scanf("%d", &n);
struct Time time[n];
for(i = 0; i < n; i++)
scanf("%d %d", &time[i].hour, &time[i].minute);
for(i = 0; i < n; i++)
printf("%d\n", 1440 - (time[i].minute + time[i].hour * 60));
return 0;
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 17de26ad22f0db136301abb492d8e327 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h>
int main()
{
int h,m,minLeft,testcase;
scanf("%d",&testcase);
for(int i=0;i<testcase;i++)
{
scanf("%d",&h);
scanf("%d",&m);
minLeft=1440-((h*60)+m);
printf("%d\n",minLeft);
}
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 3da6ca5e491c2f8d18c3dc5855bb337d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h>
int main(void){
int hour,minutes,cases;
scanf("%d",&cases);
for(int i=0;i<cases;i++){
scanf("%d %d",&hour,&minutes);
printf("%d\n",(24-hour-1)*60+(60-minutes));
}
return 0;
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 6d402402e7cbdead23c318ec81c326fe | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h>
int main(void) {
int h,m,t[1439],n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d",&h,&m);
t[i]=((23-h)*60)+(60-m);
}
for(i=0;i<n;i++)
{
printf("%d\n",t[i]);
}
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 7a646ce382bfd6cb31d4f3f9b200f8d0 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h>
int tet(int h, int m){
if((0>=h && h>24) || (0>=m && m>60))
return 0;
else return 1;
}
int main(){
int t;
scanf("%d",&t);
for(int i=1;i<=t;i++){
int h,m;
scanf("%d%d",&h,&m);
int sp=(23-h)*60+(60-m);
if(tet(h,m))
printf("%d\n",sp);
}
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 26e469583f7a166ebef4509500b10d00 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] |
#include<stdio.h>
int main()
{
int hour, min, new_year= 1440, result, c_min,i,n;
scanf("%d",&n);
for( i=0 ; i<n ; i++)
{
scanf("%d %d",&hour,&min);
if(0 <= min < 60 && 0 <= hour < 24)
{
c_min = (hour*60) + min;
result = new_year - c_min ;
printf("%d\n",result);
}
}
return 0;
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | c53ab44b7e30cc631281e5aec95335fb | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int t,i,a,b,h;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%d %d",&a,&b);
h=((23-a)*60)+(60-b);
printf("%d\n",h);
}
return 0;
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 77974ea34da3a5cead81d76a9c0c9450 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int t,h,m;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
scanf("%d%d",&h,&m);
printf("%d\n",((23-h)*60)+(60-m));
}
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | db2466ea8bff526bd0512cf68766826d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] |
#include <stdio.h>
int main()
{ int t,i,arr[3000];
scanf("%d",&t);
for(i=0;i<2*t;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<2*t;i=i+2)
{
printf("%d\n", 1440-(60*arr[i]+arr[i+1]));
}
return 0;
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 4cb129af57a2f7270848e93245b59239 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int m,h,ml=0;
scanf("%d %d",&h,&m);
if(h==23)
{
ml+=60-m;
}
else
{
ml+=(24-h)*60;
ml-=m;
}
printf("%d\n",ml);
}
return 0;
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 2921f14d011ab41e4530d87884ab877e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h>
int main()
{ int t;
scanf("%d",&t);
while(t-->0)
{
int h,m,result;
scanf("%d %d",&h,&m);
result=24*60-h*60-m;
printf("%d\n",result);
}
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 2190d132864ce4e49ea8ff4a49fc2884 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int c,i;
scanf("%d", &c);
for(i=0;i<c;i++)
{
int h,m;
scanf("%d%d",&h,&m);
int x=(24-h)*60-m;
printf("%d\n",x);
}
return 0;
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 02e3e96dd07a3278ee3bd732cbc3e97e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int c,i;
scanf("%d", &c);
for(i=0;i<c;i++)
{
int h,m;
scanf("%d %d",&h,&m);
int x=(24-h)*60-m;
printf("%d\n",x);
}
return 0;
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 1602bf7b56401c8f332dd3b4cb1e2ba0 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int a,b,i,j,n,m,t=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
t=0;
scanf("%d %d",&a,&b);
t=(24-a-1)*60+60-b;
printf("%d\n",t);
}
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 204522a9c316c6c1edba84cb243ac734 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int saat,dakika,i,kactane;
scanf("%d",&kactane);
for(i=0;i<kactane;i++)
{
scanf("%d %d",&saat,&dakika);
printf("%d\n",1440-(saat*60+dakika));
}
return 0;
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | e3404fa82ffdf9cc393878291589ae04 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int t,h,m,c,i,j,t_min;
scanf("%d",&t);
int arr[t];
if(t>=1 && t<=1439)
{
for(j=1;j<=t;j++)
{
c=0;
scanf("%d%d",&h,&m);
for(i=h;i<24;i++)
c++;
if(m==60)
{
m=0;
c--;
}
else if(m==0)
m=m;
else if(m>=1 && m<60)
{
m=60-m;
c--;
}
arr[j]=(c*60) + m;
}
for(j=1;j<=t;j++)
{
printf("%d\n",arr[j]);
}
}
return 0;
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 3095bdd2b78bfff293eedd0ff206ad2f | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int t,i,h,m;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d%d",&h,&m);
printf("%d\n",1440-h*60-m);
}
return 0;
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 50d0dfa6c64d1e9dfcf8067e1c8001c8 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int h,m,t;
scanf("%d",&t);
while(t--){
scanf("%d%d",&h,&m);
printf("%d\n",((24-h)*60-m));
}
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 262eed535803742e76b0e9404646657e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int t,h,m,i,x,y;
scanf("%d",&t);
for(i=1;i<=t;i++){
scanf("%d %d", &h, &m);
x=(h*60)+m;
y=1440-x;
if(y<=0)
y=0;
printf("%d\n",y);
}
return 0;
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 0a0f14a17a63e111e53774b30d06e8ad | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h>
int main()
{
int t;
int a,b,c,d;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&a,&b);
c=(23-a)*60;
c=c+(60-b);
printf("%d\n",c);
}
return 0;
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | d74a50e500efd27c7430e187737f10cc | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h>
#include <math.h>
int main(){
int t,h,m;
scanf("%d",&t);
while(t--){
scanf("%d%d",&h,&m);
int time_intit = h*60 + m;
int time_exit = 24*60;
int time_req = time_exit - time_intit;
printf("%d\n",time_req);
}
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | b5f196e16b765fc4b017dcf4226ed02d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int h,m;
scanf("%d",&h);
scanf("%d",&m);
int hrleft = 23-h;
int minleft = 60 - m;
int totminleft = hrleft*60 + minleft;
printf("%d\n",totminleft);
}
return 0;
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 724caa5cd9250282a97a379971b87a53 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int t,h,m,i,x;
scanf("%d",&t);
for(i=1;i<=t;i++) {
scanf("%d%d",&h,&m);
x=1440-((h*60)+m);
printf("%d\n",x);
}
return 0;
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 1b0bab0fac85aaf6cf17fba93acf5b94 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h>
int main ()
{
int t,i=1,h,m,x;
scanf("%d", &t);
while(i<=t){
scanf("%d%d", &h, &m);
x=1440-(h*60+m);
printf("%d\n",x);
i++;
}
return 0;
}
| |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 223a3a2aad238dd9dd4fa1a087e63699 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include<stdio.h>
int main()
{
int t,q,h,m;
scanf("%d",&t);
for(q=0;q<t;q++){
scanf("%d%d",&h,&m);
printf("%d\n",(24-h)*60-m);
}
return 0;
} | |
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $$$h$$$ hours and $$$m$$$ minutes, where $$$0 \le hh < 24$$$ and $$$0 \le mm < 60$$$. We use 24-hour time format!Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $$$0$$$ hours and $$$0$$$ minutes.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer on it β the number of minutes before the New Year. | C | f4982de28aca7080342eb1d0ff87734c | 2a166cbdbb17ba6b7ba275039557e6c1 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1577552700 | ["5\n23 55\n23 0\n0 1\n4 20\n23 59"] | null | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1439$$$) β the number of test cases. The following $$$t$$$ lines describe test cases. The $$$i$$$-th line contains the time as two integers $$$h$$$ and $$$m$$$ ($$$0 \le h < 24$$$, $$$0 \le m < 60$$$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $$$h=0$$$ and $$$m=0$$$. It is guaranteed that both $$$h$$$ and $$$m$$$ are given without leading zeros. | ["5\n60\n1439\n1180\n1"] | #include <stdio.h>
int main()
{
int t,h,m,n,y,i;
scanf("%d", &t);
for (i=1; i<=t; i=i+1)
{ scanf("%d %d", &h, &m);
{
n=60-m;
y=24-(h+1);
} printf("%d\n", y*60+n);
if(h==0&& m==0)
break; }
return 0;
}
| |
Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction. From the window in your room, you see the sequence of n hills, where i-th of them has height ai. The Innopolis administration wants to build some houses on the hills. However, for the sake of city appearance, a house can be only built on the hill, which is strictly higher than neighbouring hills (if they are present). For example, if the sequence of heights is 5,β4,β6,β2, then houses could be built on hills with heights 5 and 6 only.The Innopolis administration has an excavator, that can decrease the height of an arbitrary hill by one in one hour. The excavator can only work on one hill at a time. It is allowed to decrease hills up to zero height, or even to negative values. Increasing height of any hill is impossible. The city administration wants to build k houses, so there must be at least k hills that satisfy the condition above. What is the minimum time required to adjust the hills to achieve the administration's plan?However, the exact value of k is not yet determined, so could you please calculate answers for all k in range ? Here denotes n divided by two, rounded up. | Print exactly numbers separated by spaces. The i-th printed number should be equal to the minimum number of hours required to level hills so it becomes possible to build i houses. | C | 9534b468bfb6126fc16b896532ced8c5 | ae9c11b25fce2e6d549ed1fbb081503f | GNU C | standard output | 512 megabytes | train_000.jsonl | [
"dp"
] | 1532938500 | ["5\n1 1 1 1 1", "3\n1 2 3", "5\n1 2 3 2 2"] | NoteIn the first example, to get at least one hill suitable for construction, one can decrease the second hill by one in one hour, then the sequence of heights becomes 1,β0,β1,β1,β1 and the first hill becomes suitable for construction.In the first example, to get at least two or at least three suitable hills, one can decrease the second and the fourth hills, then the sequence of heights becomes 1,β0,β1,β0,β1, and hills 1,β3,β5 become suitable for construction. | PASSED | 1,900 | standard input | 1 second | The first line of input contains the only integer n (1ββ€βnββ€β5000)βthe number of the hills in the sequence. Second line contains n integers ai (1ββ€βaiββ€β100β000)βthe heights of the hills in the sequence. | ["1 2 2", "0 2", "0 1 3"] | #include <stdio.h>
int max(int a, int b) {return (a>b?a:b);}
int min(int a, int b) {return (a<b?a:b);}
int n, a[5002], dp[5001][2501][2];
int main() {
int i, j;
scanf("%d", &n);
for (i = 1 ; i <= n ; i++) scanf("%d", &a[i]);
for (i = 0 ; i <= 5000 ; i++) {
for (j = 0 ; j <= 2500 ; j++) {
dp[i][j][0] = dp[i][j][1] = 1000000000;
}
}
for (i = 0 ; i <= n ; i++) dp[i][0][0] = 0;
dp[1][1][1] = 0;
for (i = 2 ; i <= n ; i++) {
for (j = 1 ; j <= (n + 1) / 2 ; j++) {
dp[i][j][0] = min(dp[i - 1][j][0], dp[i - 1][j][1] + max(0, a[i] - a[i - 1] + 1));
dp[i][j][1] = min(dp[i - 2][j - 1][0] + max(0, a[i - 1] - a[i] + 1), dp[i - 2][j - 1][1] + max(max(0, a[i - 1] - a[i - 2] + 1), max(0, a[i - 1] - a[i] + 1)));
}
}
for (i = 1 ; i <= (n + 1) / 2 ; i++) {
printf("%d ", min(dp[n][i][0], dp[n][i][1]));
}
} | |
In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing in the string as a substring. For example, the strings "abc" and "abca" suit him, while the string "aba" doesn't. He also want the number of letters 'c' in his string to be as little as possible. | Print the string that satisfies all the constraints. If there are multiple answers, print any of them. | C | fbde86a29f416b3d83bcc63fb3776776 | 1539eaf7f1d61c8b7dfdeaf4419bac82 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"constructive algorithms"
] | 1493909400 | ["2", "3"] | NoteA palindrome is a sequence of characters which reads the same backward and forward. | PASSED | 1,000 | standard input | 1 second | The first line contains single integer n (1ββ€βnββ€β2Β·105)Β β the length of the string. | ["aa", "bba"] | #include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main() {
int n,i;
scanf("%d",&n);
for (i = 0; i < n/4; ++i)
{
printf("a");
printf("b");
printf("b");
printf("a");
}
for (i = 0; i < (n%4); ++i)
{
if (i == 0)
{
printf("a");
}
if (i == 1)
{
printf("b");
}if (i == 2)
{
printf("b");
}
}
printf("\n");
return 0;
} | |
In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing in the string as a substring. For example, the strings "abc" and "abca" suit him, while the string "aba" doesn't. He also want the number of letters 'c' in his string to be as little as possible. | Print the string that satisfies all the constraints. If there are multiple answers, print any of them. | C | fbde86a29f416b3d83bcc63fb3776776 | 3a58e7daea49f341c33675d274f16602 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"constructive algorithms"
] | 1493909400 | ["2", "3"] | NoteA palindrome is a sequence of characters which reads the same backward and forward. | PASSED | 1,000 | standard input | 1 second | The first line contains single integer n (1ββ€βnββ€β2Β·105)Β β the length of the string. | ["aa", "bba"] | #include<stdio.h>
char a[5]="aabb";
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=0; i<n; i++)
{
printf("%c",a[i%4]);
}
printf("\n");
}
}
| |
In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing in the string as a substring. For example, the strings "abc" and "abca" suit him, while the string "aba" doesn't. He also want the number of letters 'c' in his string to be as little as possible. | Print the string that satisfies all the constraints. If there are multiple answers, print any of them. | C | fbde86a29f416b3d83bcc63fb3776776 | 20be257edc6949649a66c46160e1bf6b | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"constructive algorithms"
] | 1493909400 | ["2", "3"] | NoteA palindrome is a sequence of characters which reads the same backward and forward. | PASSED | 1,000 | standard input | 1 second | The first line contains single integer n (1ββ€βnββ€β2Β·105)Β β the length of the string. | ["aa", "bba"] | #include<stdio.h>
char a[5]="aabb";
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n==3)
printf("bba\n");
else
for(int i=0; i<n; i++)
{
printf("%c",a[i%4]);
}
printf("\n");
}
}
| |
In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing in the string as a substring. For example, the strings "abc" and "abca" suit him, while the string "aba" doesn't. He also want the number of letters 'c' in his string to be as little as possible. | Print the string that satisfies all the constraints. If there are multiple answers, print any of them. | C | fbde86a29f416b3d83bcc63fb3776776 | 2cb9aad3fee39c77678db8b65f253708 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"constructive algorithms"
] | 1493909400 | ["2", "3"] | NoteA palindrome is a sequence of characters which reads the same backward and forward. | PASSED | 1,000 | standard input | 1 second | The first line contains single integer n (1ββ€βnββ€β2Β·105)Β β the length of the string. | ["aa", "bba"] | #include <stdio.h>
#include<string.h>
#define si(a) scanf("%d",&a);
#define sl(a) scanf("%lld",&a);
#define ss(a) gets(a);
#define rep(i,start,n) for(i=start;i<n;i++)
#define debugl(a) printf("%lld\n",a);
#define debugi(a) printf("%d\n",a);
int main()
{
long long int t;
sl(t);
if(t==2)printf("aa");
else if(t==3)printf("aab");
else {
int i;
rep(i,1,t+1){
if(i%4==1)printf("b");
if(i%4==2)printf("b");
if(i%4==3)printf("a");
if(i%4==0)printf("a");
}
}
}
| |
In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick.He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing in the string as a substring. For example, the strings "abc" and "abca" suit him, while the string "aba" doesn't. He also want the number of letters 'c' in his string to be as little as possible. | Print the string that satisfies all the constraints. If there are multiple answers, print any of them. | C | fbde86a29f416b3d83bcc63fb3776776 | 4a499e0823e0d47342d7c61fd26a52c6 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"constructive algorithms"
] | 1493909400 | ["2", "3"] | NoteA palindrome is a sequence of characters which reads the same backward and forward. | PASSED | 1,000 | standard input | 1 second | The first line contains single integer n (1ββ€βnββ€β2Β·105)Β β the length of the string. | ["aa", "bba"] | #include <stdio.h>
#include<stdlib.h>
int main()
{
int i,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i%4==1 || i%4==2)
printf("a");
else
printf("b");
}
printf("\n");
return 0;
}
| |
The marmots have prepared a very easy problem for this year's HC2 β this one. It involves numbers n, k and a sequence of n positive integers a1,βa2,β...,βan. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools! | Output one number. | C | 5097e92916e49cdc6fb4953b864186db | 98a4f627a095e78657a56519cfee17c9 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"greedy"
] | 1495958700 | ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and k (1ββ€βkββ€βnββ€β2200). The second line contains n space-separated integers a1,β...,βan (1ββ€βaiββ€β104). | ["5", "7", "10", "36", "100"] | #include<stdio.h>
int main()
{
int a[10000],n,m,i,sum=0,j,yes;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=1;i<n;i++){
for(j=0;j<n-i;j++)
{
if(a[j]>a[j+1])
{
yes=a[j];
a[j]=a[j+1];
a[j+1]=yes;
}
}}
for(i=0;i<m;i++)
{
sum+=a[i];
}
printf("%d",sum);
return 0;
}
| |
The marmots have prepared a very easy problem for this year's HC2 β this one. It involves numbers n, k and a sequence of n positive integers a1,βa2,β...,βan. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools! | Output one number. | C | 5097e92916e49cdc6fb4953b864186db | b36334e9c6a9fa8c0e93f32f0c2c0870 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"greedy"
] | 1495958700 | ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and k (1ββ€βkββ€βnββ€β2200). The second line contains n space-separated integers a1,β...,βan (1ββ€βaiββ€β104). | ["5", "7", "10", "36", "100"] | #include<stdio.h>
int a[100001],srx;
void abcd(int l,int r)
{int i=l,j=r,t;
int p=a[(l+r)/2];
while(i<=j)
{
while(a[i]<p)
{i++;}
while(a[j]>p)
{j--;}
if(i<=j)
{t=a[i];
a[i]=a[j];
a[j]=t;
i++;
j--;}
}
if(l<j)
abcd(l,j);
if(i<r)
abcd(i,r); }
int main()
{
int i,n,k;
scanf("%d%d",&n,&k);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
abcd(1,n);
for(i=1;i<=k;i++)
srx+=a[i];
printf("%d",srx);
return 0;
} | |
The marmots have prepared a very easy problem for this year's HC2 β this one. It involves numbers n, k and a sequence of n positive integers a1,βa2,β...,βan. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools! | Output one number. | C | 5097e92916e49cdc6fb4953b864186db | 97abee7f2aefcf8c1aaa434f633f6f50 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"greedy"
] | 1495958700 | ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and k (1ββ€βkββ€βnββ€β2200). The second line contains n space-separated integers a1,β...,βan (1ββ€βaiββ€β104). | ["5", "7", "10", "36", "100"] | #include<stdio.h>
int str[2222];
void quiksort(int a[],int low,int high)
{
int i = low;
int j = high;
int temp = a[i];
if( low < high)
{
while(i < j)
{
while((a[j] >= temp) && (i < j))
{
j--;
}
a[i] = a[j];
while((a[i] <= temp) && (i < j))
{
i++;
}
a[j]= a[i];
}
a[i] = temp;
quiksort(a,low,i-1);
quiksort(a,j+1,high);
}
else
{
return;
}
}
int main()
{
int n,k;
while(scanf("%d %d",&n,&k)!=EOF)
{
int i,sum=0;
for(i=0; i<n; i++)
{
scanf("%d",&str[i]);
}
quiksort(str,0,n-1);
for(i=0; i<k; i++)
sum+=str[i];
printf("%d\n",sum);
}
return 0;
}
| |
The marmots have prepared a very easy problem for this year's HC2 β this one. It involves numbers n, k and a sequence of n positive integers a1,βa2,β...,βan. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools! | Output one number. | C | 5097e92916e49cdc6fb4953b864186db | 2654a790af08fcfb3d7915147647b7a5 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"greedy"
] | 1495958700 | ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and k (1ββ€βkββ€βnββ€β2200). The second line contains n space-separated integers a1,β...,βan (1ββ€βaiββ€β104). | ["5", "7", "10", "36", "100"] | #include<stdio.h>
int main()
{
int n,k,a[2201],i,j,ans=0,c;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i-1;j++)
{
if(a[j]>a[j+1])
{
c=a[j];
a[j]=a[j+1];
a[j+1]=c;
}
}
}
for(i=0;i<k;i++)
{
ans=ans+a[i];
}
printf("%d",ans);
return 0;
}
| |
The marmots have prepared a very easy problem for this year's HC2 β this one. It involves numbers n, k and a sequence of n positive integers a1,βa2,β...,βan. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools! | Output one number. | C | 5097e92916e49cdc6fb4953b864186db | 04b22ed0235b4938a214f1ab64f408bb | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"greedy"
] | 1495958700 | ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and k (1ββ€βkββ€βnββ€β2200). The second line contains n space-separated integers a1,β...,βan (1ββ€βaiββ€β104). | ["5", "7", "10", "36", "100"] | #include <stdio.h>
int main() {
int i, k, n, val;
long long int sum = 0;
int ar[10001];
scanf("%d", &n);
scanf("%d", &k);
for(i = 0; i <= 10000; i++)
ar[i] = 0;
for(i = 0; i < n; i++) {
scanf("%d", &val);
ar[val]++;
//printf("%d %d ", val, ar[val]);
}
i = 0;
n = 0;
while(i < k) {
if(ar[n] > 0) {
sum += n;
i++;
ar[n]--;
}
else {
n++;
}
//printf("output");
}
printf("%lld", sum);
} | |
The marmots have prepared a very easy problem for this year's HC2 β this one. It involves numbers n, k and a sequence of n positive integers a1,βa2,β...,βan. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools! | Output one number. | C | 5097e92916e49cdc6fb4953b864186db | ce4d5ee63f27f106dd95f34a6d12f11b | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"greedy"
] | 1495958700 | ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and k (1ββ€βkββ€βnββ€β2200). The second line contains n space-separated integers a1,β...,βan (1ββ€βaiββ€β104). | ["5", "7", "10", "36", "100"] | #include<stdio.h>
int main()
{
long long int n,k,i,j,t,s=0,a[3000];
scanf("%lld %lld",&n,&k);
for(i=1;i<=n;i++)
{scanf("%lld",&a[i]);}
for(i=1;i<=k;i++)
{for(j=1;j<=n-i;j++)
{if(a[j]<a[j+1])
{t=a[j+1];
a[j+1]=a[j];
a[j]=t;
}
}
}
for(i=n;i>n-k;i--)
{s=s+a[i];}
printf("%lld",s);
return 0;
} | |
The marmots have prepared a very easy problem for this year's HC2 β this one. It involves numbers n, k and a sequence of n positive integers a1,βa2,β...,βan. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools! | Output one number. | C | 5097e92916e49cdc6fb4953b864186db | fe1dcd0af5a651d879c4c770c9249417 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"greedy"
] | 1495958700 | ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and k (1ββ€βkββ€βnββ€β2200). The second line contains n space-separated integers a1,β...,βan (1ββ€βaiββ€β104). | ["5", "7", "10", "36", "100"] | #include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
int main()
{
int i, j, n, k, sum=0;
scanf("%d %d", &n, &k);
int a[n];
for(i=0; i<n; ++i) scanf("%d", &a[i]);
for(i=0; i<n-1; ++i) {
for(j=i+1; j<n; ++j) {
if(a[i]>a[j]){
a[i] = a[i]^a[j];
a[j] = a[i]^a[j];
a[i] = a[i]^a[j];
}
}
}
for(i=0; i<k; ++i) sum += a[i];
printf("%d", sum);
return 0;
}
| |
The marmots have prepared a very easy problem for this year's HC2 β this one. It involves numbers n, k and a sequence of n positive integers a1,βa2,β...,βan. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools! | Output one number. | C | 5097e92916e49cdc6fb4953b864186db | fdc8bafa05c4a7f052325ce0ed2e7078 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"greedy"
] | 1495958700 | ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and k (1ββ€βkββ€βnββ€β2200). The second line contains n space-separated integers a1,β...,βan (1ββ€βaiββ€β104). | ["5", "7", "10", "36", "100"] | #include<stdio.h>
int main()
{
int n,a[10000],k,i,j,t,sum=0;
scanf("%d %d",&n,&k);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
for(i=0;i<k;i++)
{
sum+=a[i];
}
printf("%d",sum);
return 0;
} | |
The marmots have prepared a very easy problem for this year's HC2 β this one. It involves numbers n, k and a sequence of n positive integers a1,βa2,β...,βan. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools! | Output one number. | C | 5097e92916e49cdc6fb4953b864186db | bca8fd7f98d1e998050697b5bef892d3 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"greedy"
] | 1495958700 | ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100"] | null | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains two space-separated integers n and k (1ββ€βkββ€βnββ€β2200). The second line contains n space-separated integers a1,β...,βan (1ββ€βaiββ€β104). | ["5", "7", "10", "36", "100"] | #include<stdio.h>
#include<stdlib.h>
int fun(int [],int ,int );
int cmp(const void *,const void *);
int cmp(const void *a,const void *b)
{
return *(int *)a-*(int *)b;
}
int fun(int a[],int n,int k)
{
int i,ans=0;
qsort(a,n,sizeof(a[i]),cmp);
for(i=0;i<k;i++)
{
ans=ans+a[i];
}
return ans;
}
int main()
{
int a[10000];
int n,i,k;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("%d\n",fun(a,n,k));
return 0;
} | |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | 0f020fb4b14b9b1404bc22e6667217ea | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include<stdio.h>
#include<math.h>
int main()
{
long x,n,k,i,j,z=0,t;
scanf("%ld",&t);
while(t--){
scanf("%ld",&n);
z=1;
i=2;
j=1e9;
while(j>0){
z=pow(2,i)-1;
j=(n%z);
i++;
}
printf("%ld\n",(n/z));
}
}
| |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | 1837c1210acbcc9212baf87724a249d2 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include <stdio.h>
int main(void)
{
long long t, n, initial, sum;
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
initial = 4;
sum = 3;
while(n%sum != 0)
{
sum+=initial;
initial*=2;
}
printf("%lld\n",n/sum);
}
return 0;
}
| |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | dabc09eaca2455e1ef27ae309524e462 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int t;
scanf("%d\n",&t);
while(t--)
{
long i,n,p=1,power,num;
scanf("%ld\n",&n);
long *a=(long *)malloc(sizeof(long));
a[0]=3;
i=0;
power=2;
while(a[i]<=n)
{
power=power*2;
a[i]=power-1;
if(n%a[i]==0){
num=n/a[i];
break;}
//printf("%d ",a[i]);
}
printf("%ld\n",num);
}
} | |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | 84959501e55c2022f33f7ca314f5801e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include <stdio.h>
#include<math.h>
int main()
{
int t;
scanf("%d" ,&t);
while(t--){
long long int n,i,c=0,d=0;
scanf("%lld" ,&n);
d=(int)(log(n+1)/log(2));
for(i=2;i<=d+1;i++){
c=pow(2,i)-1;
if(n%c==0){
printf("%lld\n" ,n/c);
break;
}
}
}
return 0;
}
| |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | c3f257ccba5fee0c5bf279e1b9897b92 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include<stdio.h>
#include<stdlib.h>
long long int candies(long long int n);
int main()
{
int test,i;
scanf("%d ",&test);
long long int arr[test];
for(i=0;i<test;i++)
{
scanf("%lld",&arr[i]);
}
for(i=0;i<test;i++)
{
printf("%lld\n",candies(arr[i]));
}
}
long long int candies(long long int n)
{
long long int i,m=1,sum=1;
for(i=2;;i++)
{
sum=sum+2*m;
m=2*m;
if(!(n%sum)){
break;
}
}
return n/sum;
}
| |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | dd5856660df9aeebb28dec53fcfdec94 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include<stdio.h>
#include<math.h>
int main()
{
int t;
scanf("%d",&t);
while(t>0)
{
long long n,sum=0,i,x=0,k;
scanf("%lld",&n);
for(k=2; ; k++)
{
i=n/(pow(2,k)-1);
for(i=i;i>0; i--)
{
sum=i*(pow(2,k)-1);
if(sum<n)
break;
if(sum==n)
{
x=i;
break;
}
}
if(sum==n)
break;
}
printf("%lld\n",x);
t--;
}
return 0;
} | |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | f017e649ce9b5b56a1c713e2ed403244 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include<stdio.h>
#include<malloc.h>
#include<math.h>
int main()
{
int flag=0,i;
int cases,k=2,z,rem;
int *arr;
double n,x;
scanf("%d",&cases);
arr=( int*)malloc(cases*sizeof(int));
for(i=0;i<cases;i++)
scanf("%d",&arr[i]);
for(i=0;i<cases;i++)
{
flag=0;k=2;
n=(double)arr[i];
while(flag!=1)
{
rem=pow(2,k)-1;
//printf("%d\n",rem);
x=n/rem;
z=(int)x;
//printf("%f\t%d\n",x,z);
if(x-z==0.0)
{
//printf("hi\n");
printf("%d\n",z);
flag=1;
break;
}
else
k++;
}
}
} | |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | 68daf7d72e4b8a0d197a78dbb141ba98 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include<math.h>
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
int n;
long k;
scanf("%d",&n);
for(k=2;;k++)
{
if(n%((long)pow(2,k)-1)==0)
break;
}
printf("%lu\n",(n/((long)pow(2,k)-1)));
}
return 0;
}
| |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | b49476b1a5be8bd4557dc3b0b82923d6 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include <stdio.h>
#include<math.h>
int main(void) {
int t;
scanf("%d",&t);
while(t)
{
long long int a,n,temp=3,i=2;
scanf("%lld",&n);
while(n%temp!=0)
{
temp=temp+pow(2,i);
i++;
}
a=n/temp;
printf("%lld\n",a);
t--;
}
return 0;
}
| |
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases. | Print one integer β any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | C | d04cbe78b836e53b51292401c8c969b2 | e06ee8c186add66ea6e3e1cf60ee3387 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"brute force",
"math"
] | 1587479700 | ["7\n3\n6\n7\n21\n28\n999999999\n999999984"] | NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$. | PASSED | 900 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) β the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. | ["1\n2\n1\n7\n4\n333333333\n333333328"] | #include <stdio.h>
#include<math.h>
int main(void) {
long int t,x,i,j,n,ans=0;
scanf("%ld",&t);
long c[t];
for(i=0;i<t;i++)
scanf("%ld",&c[i]);
for(i=0;i<t;i++){
n=0;
for(j=2;n<=c[i];j++){
n=pow(2,j)-1;
x=c[i]%n;
if (x==0)
{ans=c[i]/n;
break;}}
printf("%ld\n",ans);
}
return 0;
} | |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the temple and read the string aloud. However, nothing happened. Then Asterix supposed that a password is some substring t of the string s.Prefix supposed that the substring t is the beginning of the string s; Suffix supposed that the substring t should be the end of the string s; and Obelix supposed that t should be located somewhere inside the string s, that is, t is neither its beginning, nor its end.Asterix chose the substring t so as to please all his companions. Besides, from all acceptable variants Asterix chose the longest one (as Asterix loves long strings). When Asterix read the substring t aloud, the temple doors opened. You know the string s. Find the substring t or determine that such substring does not exist and all that's been written above is just a nice legend. | Print the string t. If a suitable t string does not exist, then print "Just a legend" without the quotes. | C | fd94aea7ca077ee2806653d22d006fb1 | cfd78b31d3adc942a9199f9ad5277d24 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"hashing",
"string suffix structures",
"binary search",
"strings"
] | 1320858000 | ["fixprefixsuffix", "abcdabc"] | null | PASSED | 1,700 | standard input | 2 seconds | You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters. | ["fix", "Just a legend"] | #include<stdio.h>
#include<string.h>
int p[1000001];
char s[1000005];
int x[27];
int main()
{
scanf("%s",&s);
int len=0;
p[len]=0;
int i=1;
int length=strlen(s)-1;
while(i<strlen(s))
{
if(s[i]==s[len])
{
len++;
p[i]=len;
i++;
}
else{
if(len!=0)
{
len=p[len-1];
}
else
{
p[i]=0;
i++;
}
}
}
if(p[length]==0)
{
printf("Just a legend");
return 0;
}
for(i=0;i<length;i++)
{
if(p[i]==p[length])
break;
}
if(i<length)
{
for(i=0;i<p[length];i++)
printf("%c",s[i]);
return 0;
}
int d=p[length];
d=p[d-1];
if(d==0)
{
printf("Just a legend");
}
else
{
for(i=0;i<d;i++)
printf("%c",s[i]);
}
return 0;
}
| |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the temple and read the string aloud. However, nothing happened. Then Asterix supposed that a password is some substring t of the string s.Prefix supposed that the substring t is the beginning of the string s; Suffix supposed that the substring t should be the end of the string s; and Obelix supposed that t should be located somewhere inside the string s, that is, t is neither its beginning, nor its end.Asterix chose the substring t so as to please all his companions. Besides, from all acceptable variants Asterix chose the longest one (as Asterix loves long strings). When Asterix read the substring t aloud, the temple doors opened. You know the string s. Find the substring t or determine that such substring does not exist and all that's been written above is just a nice legend. | Print the string t. If a suitable t string does not exist, then print "Just a legend" without the quotes. | C | fd94aea7ca077ee2806653d22d006fb1 | 5322dc0711dec1a1e1253b588e9602ce | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"hashing",
"string suffix structures",
"binary search",
"strings"
] | 1320858000 | ["fixprefixsuffix", "abcdabc"] | null | PASSED | 1,700 | standard input | 2 seconds | You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters. | ["fix", "Just a legend"] | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
#define D 10007
char in[1100000];
ull hs, st[1100000], ed[1100000];
ull pw[1100000];
int main(){
int i,j,k,l,m,n,ok,res;
while(scanf("%s",in)==1){
n = strlen(in);
res = 0;
pw[0] = 1;
rep(i,n+1) pw[i+1] = pw[i]*D;
st[0] = ed[0] = 0;
rep(i,n) st[i+1] = st[i]*D + in[i];
rep(i,n) ed[i+1] = ed[i] + in[n-1-i]*pw[i];
for(k=n-1;k;k--) if(st[k]==ed[k]){
ok = 0;
hs = 0;
rep(i,k) hs = hs*D + in[i];
REP(i,k,n-1){
hs = hs*D + in[i] - in[i-k]*pw[k];
if(hs==st[k]) ok=1;
}
if(ok){res=k; break;}
}
if(res > 0){
rep(i,res) putchar(in[i]);
puts("");
} else {
puts("Just a legend");
}
}
return 0;
}
| |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the temple and read the string aloud. However, nothing happened. Then Asterix supposed that a password is some substring t of the string s.Prefix supposed that the substring t is the beginning of the string s; Suffix supposed that the substring t should be the end of the string s; and Obelix supposed that t should be located somewhere inside the string s, that is, t is neither its beginning, nor its end.Asterix chose the substring t so as to please all his companions. Besides, from all acceptable variants Asterix chose the longest one (as Asterix loves long strings). When Asterix read the substring t aloud, the temple doors opened. You know the string s. Find the substring t or determine that such substring does not exist and all that's been written above is just a nice legend. | Print the string t. If a suitable t string does not exist, then print "Just a legend" without the quotes. | C | fd94aea7ca077ee2806653d22d006fb1 | 3429c7a868d382b98e82df7daceabc1f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"hashing",
"string suffix structures",
"binary search",
"strings"
] | 1320858000 | ["fixprefixsuffix", "abcdabc"] | null | PASSED | 1,700 | standard input | 2 seconds | You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters. | ["fix", "Just a legend"] | #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char s[1000005];
int kmp[1000005];
int n;
int
main(void)
{
while(isalpha(s[++n] = getchar()))
;
--n;
kmp[1] = 0;
int i;
for(i = 2; i <= n; ++i){
int len = kmp[i - 1];
while(len > 0 && s[len + 1] != s[i]){
len = kmp[len];
}
if(s[len + 1] == s[i]){
kmp[i] = len + 1;
} else {
kmp[i] = 0;
}
}
int len = kmp[n];
while(len > 0){
for(i = len + 1; i < n; ++i){
if(kmp[i] >= len){
int j;
for(j = 1; j <= len; ++j){
printf("%c", s[j]);
}
return 0;
}
}
len = kmp[len];
}
printf("Just a legend");
return 0;
}
| |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the temple and read the string aloud. However, nothing happened. Then Asterix supposed that a password is some substring t of the string s.Prefix supposed that the substring t is the beginning of the string s; Suffix supposed that the substring t should be the end of the string s; and Obelix supposed that t should be located somewhere inside the string s, that is, t is neither its beginning, nor its end.Asterix chose the substring t so as to please all his companions. Besides, from all acceptable variants Asterix chose the longest one (as Asterix loves long strings). When Asterix read the substring t aloud, the temple doors opened. You know the string s. Find the substring t or determine that such substring does not exist and all that's been written above is just a nice legend. | Print the string t. If a suitable t string does not exist, then print "Just a legend" without the quotes. | C | fd94aea7ca077ee2806653d22d006fb1 | 4c2421f8def60f19d46ae16f830b6ee9 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"hashing",
"string suffix structures",
"binary search",
"strings"
] | 1320858000 | ["fixprefixsuffix", "abcdabc"] | null | PASSED | 1,700 | standard input | 2 seconds | You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters. | ["fix", "Just a legend"] | #include <stdio.h>
#include <string.h>
#define EMPTY -1
char s[1000005];
int next[1000005]={EMPTY};
int sum[1000005],lens;
void getnext(void)
{
int i=0,j=EMPTY;
while (i<lens)
if (j==EMPTY || s[i]==s[j]) {
++i;
++j;
next[i]=j;
} else
j=next[j];
}
int main()
{
int i,l;
while (scanf("%s",s)!=EOF) {
lens=(int)strlen(s);
getnext();
memset(sum,0,sizeof(sum));
for (i=lens; i; --i)
sum[next[i]]+=++sum[i];
for (l=next[lens]; l; l=next[l])
if (sum[l]>=3)
break;
if (l) {
for (i=0; i<l; ++i)
putchar(s[i]);
puts("");
} else
puts("Just a legend");
}
return 0;
} | |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the temple and read the string aloud. However, nothing happened. Then Asterix supposed that a password is some substring t of the string s.Prefix supposed that the substring t is the beginning of the string s; Suffix supposed that the substring t should be the end of the string s; and Obelix supposed that t should be located somewhere inside the string s, that is, t is neither its beginning, nor its end.Asterix chose the substring t so as to please all his companions. Besides, from all acceptable variants Asterix chose the longest one (as Asterix loves long strings). When Asterix read the substring t aloud, the temple doors opened. You know the string s. Find the substring t or determine that such substring does not exist and all that's been written above is just a nice legend. | Print the string t. If a suitable t string does not exist, then print "Just a legend" without the quotes. | C | fd94aea7ca077ee2806653d22d006fb1 | 18a162f36ff876981253e2056d0b6183 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"hashing",
"string suffix structures",
"binary search",
"strings"
] | 1320858000 | ["fixprefixsuffix", "abcdabc"] | null | PASSED | 1,700 | standard input | 2 seconds | You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters. | ["fix", "Just a legend"] | #include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define MAX 10001000
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
char str[MAX];
bool valid[MAX];
int n, Z[MAX], ar[MAX];
int main(){
int i, j, k, l, r, p;
while (scanf("%s", str) != EOF){
n = strlen(str);
Z[0] = n, l = 0, r = 0;
for (i = 1; i < n; i++){
if (i > r){
k = 0;
while ((i + k) < n && str[i + k] == str[k]) k++;
Z[i] = k;
if (Z[i]) l = i, r = i + Z[i] - 1;
}
else{
p = i - l;
if (Z[p] < (r - i + 1)) Z[i] = Z[p];
else{
k = r + 1;
while (k < n && str[k - i] == str[k]) k++;
l = i, r = k - 1;
Z[i] = (r - l + 1);
}
}
}
if (n <= 2){
puts("Just a legend");
continue;
}
ar[0] = 0;
int res = 0;
for (i = 1; i < n; i++){
ar[i] = ar[i - 1];
if (Z[i] > ar[i]) ar[i] = Z[i];
}
for (i = 1; i < n; i++){
int len = n - i;
if (len == Z[i] && ar[i - 1] >= Z[i] && Z[i] > res) res = Z[i];
}
if (!res) puts("Just a legend");
else{
str[res] = 0;
puts(str);
}
}
return 0;
} | |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the temple and read the string aloud. However, nothing happened. Then Asterix supposed that a password is some substring t of the string s.Prefix supposed that the substring t is the beginning of the string s; Suffix supposed that the substring t should be the end of the string s; and Obelix supposed that t should be located somewhere inside the string s, that is, t is neither its beginning, nor its end.Asterix chose the substring t so as to please all his companions. Besides, from all acceptable variants Asterix chose the longest one (as Asterix loves long strings). When Asterix read the substring t aloud, the temple doors opened. You know the string s. Find the substring t or determine that such substring does not exist and all that's been written above is just a nice legend. | Print the string t. If a suitable t string does not exist, then print "Just a legend" without the quotes. | C | fd94aea7ca077ee2806653d22d006fb1 | ec6114bbd846a99a1f8d37726c6c437b | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"hashing",
"string suffix structures",
"binary search",
"strings"
] | 1320858000 | ["fixprefixsuffix", "abcdabc"] | null | PASSED | 1,700 | standard input | 2 seconds | You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters. | ["fix", "Just a legend"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 1000009
int z[N];
char str[N];
int maxz[N];
int max(int a,int b){return a>b?a:b;}
int main()
{
int n,i,j;
int L=0,R=0;
scanf("%s",str);
n = strlen(str);
for(i=1;i<n;i++)
{
if(i>R)
{
L=i;
R=i;
while(R<n && str[R-L] == str[R]) R++;
z[i] = R-L; R--;
}
else
{
int k = i-L;
if(z[k]<R-i+1)
{
z[i]= z[k];
}
else
{
L=i; //R=i;
while(R<n && str[R-L]==str[R]) R++;
z[i] = R-L; R--;
}
}
if(i==1)
maxz[i] = z[i];
else
maxz[i] = (z[i]>maxz[i-1])?z[i]:maxz[i-1];
}
// for(i=1;i<n;i++) printf("%d ",z[i]);
//printf("\n");
int maxl = 0;
for(i=2;i<n;i++)
{
int k = z[i];
if(k==0)continue;
if(k+i == n)
{
if(maxz[i-1] >= k )
{
maxl = k;
break;
}
}
}
if(maxl == 0)
printf("Just a legend\n");
else
{
str[maxl]='\0';
printf("%s\n",str);
}
return 0;
}
| |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the temple and read the string aloud. However, nothing happened. Then Asterix supposed that a password is some substring t of the string s.Prefix supposed that the substring t is the beginning of the string s; Suffix supposed that the substring t should be the end of the string s; and Obelix supposed that t should be located somewhere inside the string s, that is, t is neither its beginning, nor its end.Asterix chose the substring t so as to please all his companions. Besides, from all acceptable variants Asterix chose the longest one (as Asterix loves long strings). When Asterix read the substring t aloud, the temple doors opened. You know the string s. Find the substring t or determine that such substring does not exist and all that's been written above is just a nice legend. | Print the string t. If a suitable t string does not exist, then print "Just a legend" without the quotes. | C | fd94aea7ca077ee2806653d22d006fb1 | d5e0ab2fd0aeb1afa84652c0d0d6e93e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"hashing",
"string suffix structures",
"binary search",
"strings"
] | 1320858000 | ["fixprefixsuffix", "abcdabc"] | null | PASSED | 1,700 | standard input | 2 seconds | You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters. | ["fix", "Just a legend"] | // Author: Ernesto Carvajal Lastres. Madrid, Spain.
#include <stdio.h>
#include <string.h>
#define maxn 1000002
char s[maxn]; int pre[maxn]; int mark[maxn];
int main()
{
gets(s + 1);
int len = strlen(s + 1) + 1;
int j = 0, i;
for (i = 2; i < len; i++)
{
while (j > 0 && s[j + 1] != s[i]) j = pre[j];
if (s[j + 1] == s[i]) j++;
pre[i] = j;
}
for (i = 1; i < len - 1; i++) mark[pre[i]] = 1;
int slen = pre[len - 1];
while (slen > 0 && !mark[slen]) slen = pre[slen];
s[slen + 1] = 0;
puts(slen > 0 ? s + 1 : "Just a legend");
return 0;
}
| |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the temple and read the string aloud. However, nothing happened. Then Asterix supposed that a password is some substring t of the string s.Prefix supposed that the substring t is the beginning of the string s; Suffix supposed that the substring t should be the end of the string s; and Obelix supposed that t should be located somewhere inside the string s, that is, t is neither its beginning, nor its end.Asterix chose the substring t so as to please all his companions. Besides, from all acceptable variants Asterix chose the longest one (as Asterix loves long strings). When Asterix read the substring t aloud, the temple doors opened. You know the string s. Find the substring t or determine that such substring does not exist and all that's been written above is just a nice legend. | Print the string t. If a suitable t string does not exist, then print "Just a legend" without the quotes. | C | fd94aea7ca077ee2806653d22d006fb1 | 9fe195217727deac41dfea6bb9c16a0a | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"hashing",
"string suffix structures",
"binary search",
"strings"
] | 1320858000 | ["fixprefixsuffix", "abcdabc"] | null | PASSED | 1,700 | standard input | 2 seconds | You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters. | ["fix", "Just a legend"] | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXN 2000015
void KMP (char data[MAXN], int N, int a[MAXN])
{
a[0] = 0;
int i, j, cnt;
for (i = 1; i < N; i++)
{
j = a[i-1];
while (j > 0)
{
if (data[j] == data[i]) break;
j = a[j-1];
}
cnt = j;
if (data[j] == data[i]) cnt++;
a[i] = cnt;
}
}
int main ()
{
static char data[MAXN];
static char s[MAXN];
int N;
scanf("%s",data);
N = strlen(data);
static int a[MAXN];
static int b[MAXN];
KMP(data,N,a);
int res = a[N-1];
if (res == 0)
{
printf("Just a legend\n");
return 0;
}
memcpy(&(s[0]),&(data[0]),res);
s[res] = '@';
memcpy(&(s[res+1]),&(data[1]),N-2);
KMP(s,res+N-1,b);
char flag = 0;
int i;
for (i = res+1; i < res+N-1; i++)
{
if (b[i] == res)
{
flag = 1;
break;
}
}
if (flag)
{
data[res] = 0;
printf("%s\n",data);
}
else
{
res = a[res-1];
if (res == 0)
{
printf("Just a legend\n");
}
else
{
data[res] = 0;
printf("%s\n",data);
}
}
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 23753ebae7b8aa6fd4a1eb29c4ed9e37 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main()
{
long n,i,s,max=-20;
scanf("%ld",&n);
long a;
for(i=0;i<n;i++){
scanf("%ld",&a);
if(max<a)
max=a;
}
printf("%ld",max);
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 8a355be22903df6a670f7bd7a688fdfc | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main ()
{
int n,i,max=-9999,x;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d",&x);
if(max<x) max=x;
}
printf("%d",max);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 526f0a860bbe25cc91e9ca3f9d046dfc | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
main () {int i,a,max=0,c; scanf("%d",&a);for(i=0;i<a;i++){scanf("%d",&c);if(c>max)max=c;}printf("%d",max); return 0;}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 24eff8b4fa14527b33808d57ad36cea9 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int m(int prev,int money,int energy,int itr,int size);
int main()
{
int n,i;
scanf("%d",&n);
i= m(0,0,0,0,n);
printf("%d\n",i);
return 0;
}
int m(int prev,int money,int energy,int itr,int size){
if(itr==size) return money;
int curr,energyn; scanf("%d",&curr);
energyn= energy+ prev-curr;
if(energyn<0){
money=money-energyn;
return m(curr,money,0,itr+1,size);
}else return m(curr,money,energyn,itr+1,size);
} | |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | d3f25a807a165a8590c29d891fcf9d36 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int m(int prev,int money,int energy,int itr,int size);
int main()
{
int n,i;
scanf("%d",&n);
i= m(0,0,0,0,n);
printf("%d\n",i);
return 0;
}
int m(int prev,int money,int energy,int itr,int size){
if(itr==size) return money;
int curr,energyn; scanf("%d",&curr);
energyn= energy+ prev-curr;
if(energyn<0){
money=money-energyn;
return m(curr,money,0,itr+1,size);
}else return m(curr,money,energyn,itr+1,size);
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | f805fb8203efe2612ce2aa9c6887aadc | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int main(){
int n;
scanf("%d", &n);
int h[100000], i;
for(i = 0; i < n; ++i) scanf("%d", &h[i]);
long long sum = -h[0], min = -h[0];
for(i = 1; i < n; ++i){
sum += h[i-1] - h[i];
if(sum < min) min = sum;
}
printf("%I64d\n", -min);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | aa375cce3002494e1b5ef7eae405c1c7 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int main(){
int n, in, max = 0;
scanf("%d", &n);
while(n-- > 0){
scanf("%d", &in); if(in > max) max = in;
}
printf("%d\n", max);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 6228fc7e77e2b976f095494a30721230 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main()
{
int dollars,n,pylon[100000],i,energy,height,flag;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
scanf("%d",&pylon[i]);
energy=0;
height=0;
dollars=0;
for(i=0;i<n;i++)
{
flag=0;
if(energy>=(pylon[i]-height))
{
energy-=pylon[i]-height;
height=pylon[i];
flag=1;
}
else
{
height+=energy;
energy=0;
}
if(!flag)
{
dollars+=pylon[i]-height;
height=pylon[i];
}
}
printf("%d\n",dollars);
}
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | bf494e54f1bc4d267c5219b8d946fa2b | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | /*BISMILLAHIRRAHMANIRRAHIM*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<time.h>
#define max(x,y) ((x>y) ? (x) : (y))
#define min(x,y) ((x<y) ? (x) : (y))
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define ROF(i,a,b) for(i=a;i>=b;i--)
#define Pi(x) printf("%d",x)
#define S1(x) scanf("%d",&x)
#define Pc(x) printf("%c",x)
#define S2(x,y) scanf("%d %d",&x,&y)
int i,j,s,a,b,t,n,m,top,min=1000,arr[10000],dizi[10000],yeni[10000],max=-1000,k,x,y,p,temp,snc,k,sayac,sum;
char c,acc[10000],cvp[4001][20],C1[4001][20],C2[4001][20];
int main(){
S1(a);
FOR(i,1,a) {S1(x);if(x>s) s=x;}
Pi(s);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 075b2c1ecba492e758afc20b60328b1c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int main()
{
int n,i,j,sum=0,energy=0;
scanf("%d",&n);
int a[n+1];
a[0]=0;
for(i=1;i<n+1;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
if(a[i]<a[i+1] && energy==0)
sum = sum + a[i+1]-a[i];
else if(a[i]>=a[i+1])
energy = energy +a[i]-a[i+1];
else if(a[i]<a[i+1] && energy>0)
{
if(a[i]+energy>=a[i+1])
energy= abs(a[i+1]-a[i]-energy);
else
{
sum = sum+ a[i+1]-a[i]-energy;
energy=0;
}
}
}
printf("%d",sum);
return 0;
} | |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 1ad1a3d4a7581199badc2b224dd9df6d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main()
{
long long int n,i,j,t,max=0;
scanf("%lld",&n);
long long int ara[100000];
for(i=0;i<n;i++)
{
scanf("%lld",&ara[i]);
if(ara[i]>max)
{
max=ara[i];
}
}
printf("%lld\n",max);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | e0a87d57779d86fb9078a02145b7b8dc | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main()
{
int n,i,count=0,count1=0;
scanf("%d",&n);
int arr[n+1],check[n];
arr[0] = 0;
for(i=1;i<=n;i++)
{
scanf("%d",&arr[i]);
check[i-1] = arr[i-1] - arr[i];
}
//for(i=0;i<n;i++)
// printf("%d\n",check[i]);
for(i=0;i<n;i++)
{
if(check[i]>=0)
count += check[i];
// printf("%d\n",count);
else if(check[i]<0 && count<(-check[i]))
{
// printf("yes\n");
count1 += (-check[i] - count);
count = 0;
//printf("%d\n",count1);
}
else if(check[i]<0 && count>=(-check[i]))
count = count + check[i];
}
printf("%d\n",(count1));
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 96b4105b8d4c6b6d1f65329cb175abfc | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main()
{
int n,i,s=0,a;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a);
if(a>s)
s=a;
}
printf("%d",s);
} | |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | d51bc50c28c6dbfd0732526a68783ef0 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main()
{
long long int n,i,s=0,a,b=0;
scanf("%I64d",&n);
for(i=1;i<=n;i++)
{
scanf("%I64d",&a);
if(a>s)
s=a;
}
printf("%I64d",s);
} | |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 2939a62ea33dda5d4108c0d381d3d1f1 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | p,m;main(n){scanf("%d",&n);while(n--){scanf("%d",&p);m=m<p?p:m;}return printf("%d",m)?0:0;} | |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 13d13509d770347acc1e0d239957a7fe | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | p,m;main(n){scanf("%d",&n);while(n--){scanf("%d",&p);m=m<p?p:m;}printf("%d",m);return 0;}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | fd8129642eca38d30ff7e7b3e2d5bc26 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main(){
int n;
scanf("%d",&n);
int i;
int minmoney = 0 ;
int h[100010];
h[0] = 0;
for ( i = 1 ; i < n+1 ; i ++){
scanf("%d",&h[i]);
}
int energy = 0;
for ( i = 0 ; i < n ; i ++ ){
if ( energy + h[i] - h[i+1] < 0 ){
minmoney += h[i+1] - h[i] - energy;
h[i] = h[i+1] - energy ;
}
energy += h[i] - h[i+1];
}
printf("%d\n",minmoney);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 89d9e8409a7bc695a8d7ba7d2689a731 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int main ()
{
int i,n,x[200000],cost,z,e,max=-1;
scanf("%d",&n);
for(i=1;i<=n;i++) {
scanf("%d",&x[i]);
if(x[i]>max) {
max=x[i];
}
}
cost=max;
printf("%d\n",cost);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | bfd601efcc118bf08b04ac7d37e6efa1 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int main()
{
int i,n,a,max;
scanf("%d",&n);
for (i=1;i<=n;i++)
{
scanf("%d",&a);
if (a>max) max=a;
}
printf("%d",max);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | e58373557f0977a7d0c889f0b2eb8844 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int main()
{
int n;
int i,j,val;
int money = 0,energy = 0;
scanf("%d",&n);
int hPrev = 0;
for(i=0;i<n;i++){
scanf("%d",&val);
if((hPrev - val)>=0){
energy += (hPrev - val);
// printf("Energy1 = %d\n",energy);
}
else{
int a = val- hPrev;
if(energy - a >=0){
energy -= a;
// printf("Energy2 = %d\n",energy);
}
else{
money += (a-energy);
energy = 0;
//printf("%d %d %d\n",money,a-energy,i);
}
}
hPrev = val;
}
printf("%d\n",money);
return 0;
} | |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 229c0be7926335e35aa3115f1c96618d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main()
{
int n, num, hold=0, sum=0, i, prev=0;
scanf("%d", &n);
for(i=0;i<n;i++){
scanf("%d", &num);
if(hold<=num-prev){
sum+= num - prev ;
sum += - hold;
hold=0;
}
else{
hold+=prev-num;
}
prev = num;
}
printf("%d", sum);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | c4e14e3719c4d5701948aeb4033b1374 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int main(){
int n, prev = 0, actual, res = 0, energy = 0;
scanf("%d", &n);
while(n--){
scanf("%d", &actual);
energy += -(actual-prev);
if(energy < 0){
res -= energy;
energy = 0;
}
prev = actual;
}
printf("%d\n", res);
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 07ef9033bb936a46e9db69a6daaa32ac | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
#define MAX(a, b) ((a > b) ? a : b)
int main(){
int n, res = 0, aux;
scanf("%d", &n);
while(n--){
scanf("%d", &aux);
res = MAX(res, aux);
}
printf("%d\n", res);
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | f45d1dfcd62fc0ee9f3c05749434292c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main(){
long int n,m=0,k=0;
scanf("%ld",&n);
int i;
for(i=0;i<n;i++)
{
scanf("%ld",&k);
if(m<k)
m=k;
}
printf("%ld",m);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | b9febb2420e7d210f51fd8854847d9e8 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
#include<math.h>
int height[100001];
int main()
{
int n,i,abso,diff=0;
int ans=0,energy=0;
scanf("%d",&n);
height[0]=0;
for(i=1;i<=n;i++)
{
scanf("%d",&height[i]);
}
ans=0,energy=0;
for(i=1;i<=n;i++)
{
diff=height[i-1]-height[i];
if(diff>=0)
energy+=diff;
else
{
abso=-diff;
if(abso<=energy)
{
energy=(energy-abso);
}
else
{
ans=ans+(abso-energy);
energy=0;
}
}
}
printf("%d\n",ans);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | c7a0a32c168adadbd2da1e15255cd654 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main()
{
long long n,x,temp,diff,i,energy=0,amt=0;
scanf("%lld",&n);
for(i=0;i<n;++i)
{
scanf("%lld",&x);
if (i==0)
{ amt+=x;
temp=x;
}
else
{
diff=temp-x;
temp=x;
energy+=diff;
if (energy<0)
{ amt+=(-energy);
energy=0;}
}
}
printf("%lld",amt);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 50ea99d6bdf1d97b1366afce56839c5f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | /*
* util.c
*
* Created on: 30 οΏ½οΏ½οΏ½οΏ½ 2014 οΏ½.
* Author: ulgish
*/
#define DEBUG
#define TIME_COMPUTE
#define START_TIME \
clock_t _start_time = clock();
#define END_TIME \
_start_time = (clock() - _start_time);\
long ms = _start_time % CLOCKS_PER_SEC;\
_start_time = _start_time / CLOCKS_PER_SEC;\
printf("%lds %ldms", (long)(_start_time), ms);\
#ifdef TIME_COMPUTE
#include <time.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(A,B) (((A) > (B))?(A):(B))
#define MIN(A,B) (((A) < (B))?(A):(B))
#define LN printf("\n")
#define TAB printf("\t")
#define SPACE printf(" ")
typedef unsigned long long uint64;
typedef long long int64;
typedef short int16;
typedef unsigned char byte;
void int64_print(int64 n){
int64 carry = 10;
char buf[20];
if (n == 0){
printf("0");
return;
}
if (n < 0){
printf("-");
n *= -1;
}
buf[0] = '\0';
int i = 0, j;
while (n > 0){
buf[i] = n % carry;
n = n / carry;
i += 1;
}
i--;
for (j = i; j>= 0; j--){
printf("%c", 48 + buf[j]);
}
fflush(stdin);
}
void uint64_print(uint64 n){
uint64 carry = 10;
char buf[20];
if (n == 0){
printf("0");
return;
}
buf[0] = '\0';
int i = 0, j;
while (n > 0){
buf[i] = n % carry;
n = n / carry;
i += 1;
}
i--;
for (j = i; j>= 0; j--){
printf("%c", 48 + buf[j]);
}
fflush(stdin);
}
uint64 uint64_read(){
char* s = (char*) calloc(20, sizeof(char));
s[0] = '\0';
scanf("%s", s);
//printf("=======%s\n", s);
uint64 ret = 0;
uint64 carry = 1;
int len = strlen(s), i;
for (i = 0; i < len; i++){
ret += carry * (s[len-1-i] - 48);
carry*=10;
};
free(s);
return ret;
}
int64 int64_read(){
char* s = (char*) calloc(21, sizeof(char));
s[0] = '\0';
scanf("%s", s);
//printf("=======%s\n", s);
int64 ret = 0;
int64 carry = 1;
byte neg = 0;
if (s[0] == '-'){
neg = 1;
}
int len = strlen(s), i;
for (i = 0 + neg; i < len; i++){
ret += carry * (s[len-1 - (i - neg)] - 48);
carry*=10;
};
if (neg){
ret *= -1;
}
free(s);
return ret;
}
typedef struct{
void* val;
void* prev;
}node;
typedef node* nodep;
#define FUNC_PTR(NAME) void (* (NAME))(void* arg)
typedef struct{
int len;
nodep first;
nodep last;
FUNC_PTR(free_func);
FUNC_PTR(print_func);
}q;
typedef q* qp;
qp q_create(FUNC_PTR(free_func), FUNC_PTR(print_func)){
qp ret = (qp) malloc(sizeof(q));
ret->free_func = free_func;
ret->print_func = print_func;
ret->first = NULL;
ret->last = NULL;
ret->len = 0;
return ret;
}
qp q_add(qp arg, void* val){
nodep no = (nodep) malloc(sizeof(node));
no->prev = NULL;
no->val = val;
if (arg->len == 0){
arg->first = no;
arg->last = no;
arg->len = 1;
}else{
arg->last->prev = no;
arg->last = no;
arg->len++;
}
return arg;
}
qp q_push(qp arg, void* val){
nodep no = (nodep) malloc(sizeof(node));
no->prev = NULL;
no->val = val;
if (arg->len == 0){
arg->first = no;
arg->last = no;
arg->len = 1;
}else{
no->prev = arg->first;
arg->first = no;
arg->len++;
}
return arg;
}
void* q_first(qp arg){
return arg->first->val;
}
qp q_pop(qp arg){
nodep no = arg->first;
if (no != NULL){
arg->free_func(no->val);
}
if (arg->len > 0){
arg->len--;
arg->first = no->prev;
free(no);
}
return arg;
}
byte q_empty(qp arg){
return (arg->len == 0);
}
qp q_free_and_print(qp arg, byte print_len){
if (print_len)
printf("%d ", arg->len);
while (!q_empty(arg)){
arg->print_func(q_first(arg));
q_pop(arg);
}
LN;
free(arg);
arg = NULL;
return arg;
}
int main(){
int n,i;
int64 sum = 0,ans;
scanf("%d", &n);
int* a = (int*) calloc(n+1,sizeof(int));
a[0] = 0;
ans = a[0];
for (i = 0; i < n; i++){
scanf("%d", a + (i + 1));
if ((sum + (a[i] - a[i+1])*1LL) < 0){
ans += -1LL*(1LL*sum + (a[i] - a[i+1])*1LL);
sum = 0;
}else{
sum += (a[i] - a[i+1])*1LL;
}
}
if (sum < 0){
sum *= -1LL;
}
int64_print(ans);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 5a7ef0be0c07736679086687110ad8b2 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
int main()
{
long long int n,a[1000000],i;
a[0]=0;
scanf("%I64d",&n);
for(i=1;i<=n;i++)
{
scanf("%I64d",&a[i]);
}
int count=0,e=0;
for(i=1;i<(n+1);i++)
{
e=e-a[i]+a[i-1];
while(e<0)
{
e++;
count++;
}
}
printf("%d",count);
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 67c153111dba936057ff7ef9929c54d8 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int main(){
int n,a[1000005],i,b,max=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
if(max<a[i])
max=a[i];
}
printf("%d\n",max);
return 0;
} | |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 6f20fba0fe9fac9431dbd50d95d9afe2 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | /*#include<stdio.h>
int n,s,x[105],y[105],i,j,t=0,b=0,min;
int main(){
scanf("%i%i",&n,&s);
for(i=1;i<=n;i++){
scanf("%i%i",&x[i],&y[i]);
if(y[i]!=0)b=i;
}
for(i=1;i<=n;i++){
if(x[i]+1*(y[i]>0)>s)t++;
}
if(t==n)printf("-1\n");
else{
min=y[b];
for(i=1;i<=n;i++){
if(y[i]<min&&y[i]!=0&&x[i]<=s)min=y[i];
}
printf("%i\n",(100-min)*(min>0));
}
return 0;
}*/
#include<stdio.h>
int n,H[100005],i,j,tot=0,p,serah=0;
int main(){
scanf("%i",&n);
for(i=1;i<=n;i++){
scanf("%i",&H[i]);
}
for(i=1;i<=n;i++){
p=H[i-1]-H[i];
serah=serah+p;
if(serah<0){
tot=tot-serah;
serah=0;
}
}
printf("%i\n",tot);
return 0;
} | |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 092496b7f0494b601ee0f8f4d7bb9caa | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d",&n);
int arr[n];
int i;
for(i=0;i<n;i++){
scanf("%d",&arr[i]);
}
int energy =0;
int min_energy=10000;
for(i=0;i<n-1;i++){
energy = energy + (arr[i]-arr[i+1]);
if(min_energy > energy){
min_energy = energy;
}
}
if(min_energy<0){
printf("%d",arr[0]+(-min_energy));
}else{
printf("%d",arr[0]);
}
return 0;
}
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 093c5ba5a7dbf72b828d8d01c4895332 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
long ans,n,s,i,j,energy,cuenergy;
long h[100002];
scanf("%ld",&n);
for(i=0;i<n;i++)
scanf("%ld",&h[i]);
energy = 0;
cuenergy = 0;
for(i=0;i<n-1;i++){
if(h[i+1]-h[i]>0)
{
if(cuenergy>=h[i+1]-h[i])
cuenergy = cuenergy - (h[i+1]-h[i]);
else
{
energy+= abs(cuenergy - (h[i+1]-h[i]));
//cuenergy+= abs(cuenergy - (h[i+1]-h[i]));
cuenergy=0;
}
}
else cuenergy+= h[i]-h[i+1];
}
energy+= h[0];
printf("%ld\n",energy);
return 0;
}
/*
#include<iostream>
using namespace std ;
long a[1000000] = { 0 } ;
int main()
{
long n , e = 0 , ans = 0 , i ;
cin >> n ;
a[ 0 ] = 0 ;
for( i = 1 ; i <= n ; i++ )
cin >> a[ i ] ;
for( i = 1 ; i <= n ; i++ )
{
if( a[ i - 1 ] - a[ i ] < 0 )
{
if( e > a[ i ] - a[ i -1 ] )
{
e -= a[ i ] - a[ i -1 ] ;
}
else
{
ans += a[ i ] - a[ i -1 ] - e ;
e = 0 ;
}
}
else
e += a[ i - 1 ] - a[ i ] ;
}
cout << ans <<endl ;
return 0 ;
}*/
| |
Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (nβ+β1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with number i (iβ>β0) has height hi. The goal of the game is to reach n-th pylon, and the only move the player can do is to jump from the current pylon (let's denote its number as k) to the next one (its number will be kβ+β1). When the player have made such a move, its energy increases by hkβ-βhkβ+β1 (if this value is negative the player loses energy). The player must have non-negative amount of energy at any moment of the time. Initially Caisa stand at 0 pylon and has 0 energy. The game provides a special opportunity: one can pay a single dollar and increase the height of anyone pylon by one. Caisa may use that opportunity several times, but he doesn't want to spend too much money. What is the minimal amount of money he must paid to reach the goal of the game? | Print a single number representing the minimum number of dollars paid by Caisa. | C | d03ad531630cbecc43f8da53b02d842e | 7b72193499e7a34dd58e94c564b6c436 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"brute force",
"math"
] | 1409383800 | ["5\n3 4 3 2 4", "3\n4 4 4"] | NoteIn the first sample he can pay 4 dollars and increase the height of pylon with number 0 by 4 units. Then he can safely pass to the last pylon. | PASSED | 1,100 | standard input | 1 second | The first line contains integer n (1ββ€βnββ€β105). The next line contains n integers h1, h2,β..., hn (1βββ€ββhiβββ€ββ105) representing the heights of the pylons. | ["4", "4"] | #include <stdio.h>
int dollars(int a[],int n)
{
int m = a[0] - a[1],i;
int sum = 0;
for(i = 0;i < n - 1;i++)
{
sum += a[i] - a[i+1];
if(sum < m)
m = sum;
}
if(m >= 0)
return a[0];
else
return -(m-a[0]);
}
int main()
{
int n;
scanf("%d",&n);
if(n == 1)
{
int x;
scanf("%d",&x);
printf("%d\n",x);
}
else
{
int a[n],i;
for(i = 0;i < n;i++)
scanf("%d",&a[i]);
printf("%d\n",dollars(a,n));
}
return 0;
} | |
Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.You know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either paβ>βpb, or paβ=βpb and taβ<βtb. It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places yβ+β1, yβ+β2, ..., yβ+βx. The teams that performed worse than the teams from this group, get their places in the results table starting from the yβ+βxβ+β1-th place.Your task is to count what number of teams from the given list shared the k-th place. | In the only line print the sought number of teams that got the k-th place in the final results' table. | C | 63e03361531999db408dc0d02de93579 | a366ecdd7ef11572423837636ef362cc | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"binary search",
"implementation"
] | 1332516600 | ["7 2\n4 10\n4 10\n4 10\n3 20\n2 1\n2 1\n1 10", "5 4\n3 1\n3 1\n5 3\n3 1\n3 1"] | NoteThe final results' table for the first sample is: 1-3 places β 4 solved problems, the penalty time equals 10 4 place β 3 solved problems, the penalty time equals 20 5-6 places β 2 solved problems, the penalty time equals 1 7 place β 1 solved problem, the penalty time equals 10 The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.The final table for the second sample is: 1 place β 5 solved problems, the penalty time equals 3 2-5 places β 3 solved problems, the penalty time equals 1 The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams. | PASSED | 1,100 | standard input | 2 seconds | The first line contains two integers n and k (1ββ€βkββ€βnββ€β50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1ββ€βpi,βtiββ€β50) β the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces. | ["3", "4"] | #include<stdio.h>
#include<stdlib.h>
void swap(int *v1,int *v2)
{
int t;
t=*v1;
*v1=*v2;
*v2=t;
}
int main()
{
int n,i,j,pos,count=0;
int *p,*t;
scanf("%d %d",&n,&pos);
p=(int*)malloc(n*sizeof(int));
t=(int*)malloc(n*sizeof(int));
for(i=0;i<n;i++)
scanf("%d %d",&p[i],&t[i]);
for(i=0;i<n-1;i++)
{
for(j=1;j<n-i;j++)
{
if(p[j-1]<p[j])
{
swap(&p[j-1],&p[j]);
swap(&t[j-1],&t[j]);
}
if(p[j-1]==p[j] && t[j-1]>t[j])
{
swap(&t[j-1],&t[j]);
}
}
}
for(i=0;i<n;i++)
{
if(p[pos-1]==p[i] && t[pos-1]==t[i])
count++;
}
printf("%d",count);
return 0;
} | |
Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.You know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either paβ>βpb, or paβ=βpb and taβ<βtb. It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places yβ+β1, yβ+β2, ..., yβ+βx. The teams that performed worse than the teams from this group, get their places in the results table starting from the yβ+βxβ+β1-th place.Your task is to count what number of teams from the given list shared the k-th place. | In the only line print the sought number of teams that got the k-th place in the final results' table. | C | 63e03361531999db408dc0d02de93579 | 47610a9d06b7e9d613472a33d53cca48 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"binary search",
"implementation"
] | 1332516600 | ["7 2\n4 10\n4 10\n4 10\n3 20\n2 1\n2 1\n1 10", "5 4\n3 1\n3 1\n5 3\n3 1\n3 1"] | NoteThe final results' table for the first sample is: 1-3 places β 4 solved problems, the penalty time equals 10 4 place β 3 solved problems, the penalty time equals 20 5-6 places β 2 solved problems, the penalty time equals 1 7 place β 1 solved problem, the penalty time equals 10 The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.The final table for the second sample is: 1 place β 5 solved problems, the penalty time equals 3 2-5 places β 3 solved problems, the penalty time equals 1 The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams. | PASSED | 1,100 | standard input | 2 seconds | The first line contains two integers n and k (1ββ€βkββ€βnββ€β50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1ββ€βpi,βtiββ€β50) β the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces. | ["3", "4"] | #include<stdio.h>
#define swap(a,b) a^=b; b^=a; a^=b;
int main ()
{
int s=0,i,j,n,k,r[51][2];
scanf("%d%d",&n,&k); k--;
for(i=0;i<n;i++)
scanf("%d %d",&r[i][0],&r[i][1]);
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if( r[j][0]<r[j+1][0] || (r[j][0]==r[j+1][0] && r[j][1]>r[j+1][1]) )
{
swap(r[j][0],r[j+1][0])
swap(r[j][1],r[j+1][1])
}
}
}
for(i=0;i<n;i++)
if(r[i][0]==r[k][0] && r[i][1]==r[k][1])
s++;
printf("%d\n",s);
return 0;
}
| |
Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.You know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either paβ>βpb, or paβ=βpb and taβ<βtb. It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places yβ+β1, yβ+β2, ..., yβ+βx. The teams that performed worse than the teams from this group, get their places in the results table starting from the yβ+βxβ+β1-th place.Your task is to count what number of teams from the given list shared the k-th place. | In the only line print the sought number of teams that got the k-th place in the final results' table. | C | 63e03361531999db408dc0d02de93579 | 389d170079e8a6675d820cae067a51c3 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"binary search",
"implementation"
] | 1332516600 | ["7 2\n4 10\n4 10\n4 10\n3 20\n2 1\n2 1\n1 10", "5 4\n3 1\n3 1\n5 3\n3 1\n3 1"] | NoteThe final results' table for the first sample is: 1-3 places β 4 solved problems, the penalty time equals 10 4 place β 3 solved problems, the penalty time equals 20 5-6 places β 2 solved problems, the penalty time equals 1 7 place β 1 solved problem, the penalty time equals 10 The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.The final table for the second sample is: 1 place β 5 solved problems, the penalty time equals 3 2-5 places β 3 solved problems, the penalty time equals 1 The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams. | PASSED | 1,100 | standard input | 2 seconds | The first line contains two integers n and k (1ββ€βkββ€βnββ€β50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1ββ€βpi,βtiββ€β50) β the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces. | ["3", "4"] | #include <stdio.h>
int main(){
int temp,n,k,max,count,i,j;
scanf("%d%d",&n,&k);
int p[n];
int t[n];
for(i=0;i<n;i++)
scanf("%d%d",&p[i],&t[i]);
for(i=0;i<n;i++){
max = i;
for(j=i;j<n;j++){
if(p[j]>p[max])
max = j;
else if(p[j]==p[max] && t[j]<t[max])
max = j;
}
temp = p[i];
p[i] = p[max];
p[max] = temp;
temp = t[i];
t[i] = t[max];
t[max] = temp;
}
/*
for(i=0;i<n;i++)
printf("%d %d\n",p[i],t[i]);*/
count = 1;
for(i=k;i<n;i++){
if(p[i]==p[k-1] && t[i]==t[k-1])
count++;
else
break;
}
for(i=k-2;i>=0;i--){
if(p[i]==p[k-1] && t[i]==t[k-1])
count++;
else
break;
}
printf("%d\n",count);
return 0;
} | |
Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.You know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either paβ>βpb, or paβ=βpb and taβ<βtb. It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places yβ+β1, yβ+β2, ..., yβ+βx. The teams that performed worse than the teams from this group, get their places in the results table starting from the yβ+βxβ+β1-th place.Your task is to count what number of teams from the given list shared the k-th place. | In the only line print the sought number of teams that got the k-th place in the final results' table. | C | 63e03361531999db408dc0d02de93579 | 641fc962b29886538d6c84c53fa09b3b | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"binary search",
"implementation"
] | 1332516600 | ["7 2\n4 10\n4 10\n4 10\n3 20\n2 1\n2 1\n1 10", "5 4\n3 1\n3 1\n5 3\n3 1\n3 1"] | NoteThe final results' table for the first sample is: 1-3 places β 4 solved problems, the penalty time equals 10 4 place β 3 solved problems, the penalty time equals 20 5-6 places β 2 solved problems, the penalty time equals 1 7 place β 1 solved problem, the penalty time equals 10 The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.The final table for the second sample is: 1 place β 5 solved problems, the penalty time equals 3 2-5 places β 3 solved problems, the penalty time equals 1 The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams. | PASSED | 1,100 | standard input | 2 seconds | The first line contains two integers n and k (1ββ€βkββ€βnββ€β50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1ββ€βpi,βtiββ€β50) β the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces. | ["3", "4"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i, a[51][51], num, k, p, t, maxP = 0, count = 0, j, maxT = 0, test = 0;
for (i = 0; i < 51; i++){
for (j = 0; j < 51; j++){
a[i][j] = 0;
}
}
scanf("%d %d", &num, &k);
for (i = 0; i < num; i++){
scanf("%d %d", &p, &t);
if (p > maxP)
maxP = p;
if (t > maxT)
maxT = t;
a[p][t]++;
}
for (i = maxP; i > 0; i--){
for (j = 0; j <= maxT; j++){
if (a[i][j] > 0)
count += a[i][j];
if (count >= k){
printf("%d", a[i][j]);
test = 1;
break;
}
}
if (test)
break;
}
return 0;
}
| |
Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.You know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either paβ>βpb, or paβ=βpb and taβ<βtb. It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places yβ+β1, yβ+β2, ..., yβ+βx. The teams that performed worse than the teams from this group, get their places in the results table starting from the yβ+βxβ+β1-th place.Your task is to count what number of teams from the given list shared the k-th place. | In the only line print the sought number of teams that got the k-th place in the final results' table. | C | 63e03361531999db408dc0d02de93579 | 2179421f0c33c5027e0439e1da13551f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"binary search",
"implementation"
] | 1332516600 | ["7 2\n4 10\n4 10\n4 10\n3 20\n2 1\n2 1\n1 10", "5 4\n3 1\n3 1\n5 3\n3 1\n3 1"] | NoteThe final results' table for the first sample is: 1-3 places β 4 solved problems, the penalty time equals 10 4 place β 3 solved problems, the penalty time equals 20 5-6 places β 2 solved problems, the penalty time equals 1 7 place β 1 solved problem, the penalty time equals 10 The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.The final table for the second sample is: 1 place β 5 solved problems, the penalty time equals 3 2-5 places β 3 solved problems, the penalty time equals 1 The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams. | PASSED | 1,100 | standard input | 2 seconds | The first line contains two integers n and k (1ββ€βkββ€βnββ€β50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1ββ€βpi,βtiββ€β50) β the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces. | ["3", "4"] | #include <stdio.h>
#include <stdlib.h>
struct team
{
int prob ;
int penality;
};
int main()
{
int n , k , i , counter = 0 , j ;
scanf("%d%d",&n ,&k);
struct team array[n];
struct team temp ;
for(i=0 ; i < n ; i++)
{
scanf("%d",&array[i].prob);
scanf("%d",&array[i].penality);
}
for(i=1; i<n; i++)
{
temp.prob = array[i].prob ;
temp.penality = array[i].penality;
int position=i;
while((temp.prob>array[position-1].prob)||(temp.prob==array[position-1].prob&&temp.penality<array[position-1].penality)&&position>0)
{
array[position].penality=array[position-1].penality;
array[position].prob=array[position-1].prob;
position--;
}
array[position].penality=temp.penality;
array[position].prob=temp.prob;
}
temp.penality=array[k-1].penality;
temp.prob=array[k-1].prob;
for(i = 0 ; i < n ; i++)
{
if((array[i].penality==temp.penality)&&(array[i].prob==temp.prob))
counter ++ ;
}
printf("%d",counter);
return 0;
}
| |
Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.You know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either paβ>βpb, or paβ=βpb and taβ<βtb. It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places yβ+β1, yβ+β2, ..., yβ+βx. The teams that performed worse than the teams from this group, get their places in the results table starting from the yβ+βxβ+β1-th place.Your task is to count what number of teams from the given list shared the k-th place. | In the only line print the sought number of teams that got the k-th place in the final results' table. | C | 63e03361531999db408dc0d02de93579 | 4cb04944b3a610155e35501710bf8a6f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"binary search",
"implementation"
] | 1332516600 | ["7 2\n4 10\n4 10\n4 10\n3 20\n2 1\n2 1\n1 10", "5 4\n3 1\n3 1\n5 3\n3 1\n3 1"] | NoteThe final results' table for the first sample is: 1-3 places β 4 solved problems, the penalty time equals 10 4 place β 3 solved problems, the penalty time equals 20 5-6 places β 2 solved problems, the penalty time equals 1 7 place β 1 solved problem, the penalty time equals 10 The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.The final table for the second sample is: 1 place β 5 solved problems, the penalty time equals 3 2-5 places β 3 solved problems, the penalty time equals 1 The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams. | PASSED | 1,100 | standard input | 2 seconds | The first line contains two integers n and k (1ββ€βkββ€βnββ€β50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1ββ€βpi,βtiββ€β50) β the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces. | ["3", "4"] | #include"stdio.h"
#include"ctype.h"
#include"stdlib.h"
#include"string.h"
struct pair{
long first;
long second;
};
int bm=0;
int k;
struct node{
int c;
struct pair p;
struct node *left;
struct node *right;
};
int compare(struct pair p1,struct pair p2){
if((p1.first>p2.first)|| (p1.first==p2.first && p1.second<p2.second))
return 1;
if(p1.first==p2.first && p1.second==p2.second)
return 0;
return -1;
}
void InsertionSort(int n,struct pair list[]){
int i,j;
struct pair key;
for(i=1;i<n;i++){
key=list[i];
j=i-1;
while(j>=0 && compare(list[j],key)){
list[j+1]=list[j];
j--;
}
list[j+1]=key;
}
}
struct pair *merge(struct pair *l,int n,struct pair *s,int m){
int idx1=0,idx2=0,i=0;
struct pair *list=(struct pair *)malloc(sizeof(struct pair)*(m+n));
while(idx1<n && idx2<m){
if(compare(s[idx2],l[idx1])){
list[i++]=l[idx1++];
}else
list[i++]=s[idx2++];
}
while(idx1<n)
list[i++]=l[idx1++];
while(idx2<m)
list[i++]=s[idx2++];
return list;
}
struct pair *mergesort(struct pair list[],int n){
int i,j;
if(n==1)
return list;
struct pair f[n/2];
struct pair s[n-n/2];
for(i=0;i<n/2;i++)
f[i]=list[i];
for(i=n/2,j=0;i<n;i++,j++)
s[j]=list[i];
return merge(mergesort(f,n/2),n/2,mergesort(s,n-n/2),n-n/2);
}
int getline(int lim,char s[]){
char c;
int i=0;
while(isspace(c=getchar()));
for(i=0;i<lim && (c)!='\n' && !isspace(c);i++,c=getchar())
s[i]=c;
s[i]='\0';
return i;
}
struct node*add(struct node *root,struct pair p){
if(root==NULL){
root=(struct node*)malloc(sizeof(struct node));
root->p.first=p.first;
root->p.second=p.second;
root->left=root->right=NULL;
root->c=1;
}else if(compare(root->p,p)==1)
root->left=add(root->left,p);
else if(compare(root->p,p)==0)
root->c++;
else
root->right=add(root->right,p);
return root;
}
void print(struct node *t){
if(t==NULL)
return;
print(t->right);
bm+=t->c;
if(bm>=k){
printf("%d",t->c);
exit(0);
}
//printf("%d %d\n",t->p.first,t->p.second);
print(t->left);
}
int main(){
int i,j,idx;
int n;
struct pair p;
char l[20];
struct node *root=NULL;
getline(20,l);
n=atoi(l);
//int num[100000];
getline(20,l);
k=atoi(l);
/*for(i=0;i<n;i++){
getline(20,l);
num[i]=atoi(l);
//printf("%d ",num[i]);
}*/
idx=0;
for(i=0;i<(n);i++){
getline(20,l);
p.first=atoi(l);
getline(20,l);
p.second=atoi(l);
root=add(root,p);
}
print(root);
return 0;
} | |
Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.You know the rules of comparing the results of two given teams very well. Let's say that team a solved pa problems with total penalty time ta and team b solved pb problems with total penalty time tb. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either paβ>βpb, or paβ=βpb and taβ<βtb. It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places yβ+β1, yβ+β2, ..., yβ+βx. The teams that performed worse than the teams from this group, get their places in the results table starting from the yβ+βxβ+β1-th place.Your task is to count what number of teams from the given list shared the k-th place. | In the only line print the sought number of teams that got the k-th place in the final results' table. | C | 63e03361531999db408dc0d02de93579 | 9eb60777375cc9e69b14a5b6033e7f98 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"sortings",
"binary search",
"implementation"
] | 1332516600 | ["7 2\n4 10\n4 10\n4 10\n3 20\n2 1\n2 1\n1 10", "5 4\n3 1\n3 1\n5 3\n3 1\n3 1"] | NoteThe final results' table for the first sample is: 1-3 places β 4 solved problems, the penalty time equals 10 4 place β 3 solved problems, the penalty time equals 20 5-6 places β 2 solved problems, the penalty time equals 1 7 place β 1 solved problem, the penalty time equals 10 The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.The final table for the second sample is: 1 place β 5 solved problems, the penalty time equals 3 2-5 places β 3 solved problems, the penalty time equals 1 The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams. | PASSED | 1,100 | standard input | 2 seconds | The first line contains two integers n and k (1ββ€βkββ€βnββ€β50). Then n lines contain the description of the teams: the i-th line contains two integers pi and ti (1ββ€βpi,βtiββ€β50) β the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces. | ["3", "4"] | #include<stdio.h>
void merge_sort(int,int);
struct result
{
int prob;
int time;
};
struct result score[100];
struct result dummy[100];
int main()
{
int i,n,k,j,shared;
shared=-1;
scanf("%d %d",&n,&k);
k--;
for(i=0;i<n;i++)
{
scanf("%d %d",&score[i].prob,&score[i].time);
}
merge_sort(0,n-1);
// for(i=0;i<n;i++)
// {
// printf("%d %d\n",score[i].prob,score[i].time);
// }
i=k;
j=k;
while(((score[i].time==score[k].time)&&(score[i].prob==score[k].prob))||((score[j].time==score[k].time)&&(score[j].prob==score[k].prob)))
{
if((i>=0) && (score[i].time==score[k].time)&&(score[i].prob==score[k].prob))
{
i--;
shared++;
}
if((j<n) && (score[j].time==score[k].time)&&(score[j].prob==score[k].prob))
{
j++;
shared++;
}
}
printf("%d\n",shared);
}
void merge_sort(int left,int right)
{
int mid = (left+right)/2;
int i,j,ptr,ptr1,ptr2;
if(left==right)
{
return;
}
else
{
merge_sort(left,mid);
merge_sort(mid+1,right);
ptr1=left; //merge the subarrays
ptr2=mid+1;
ptr=0;
for(i=0;i<=right-left;i++)
{
if(ptr1==mid+1)
{
dummy[i]=score[ptr2];
ptr2++;
}
else if(ptr2==right+1)
{
dummy[i]=score[ptr1];
ptr1++;
}
else if(score[ptr1].prob>score[ptr2].prob)
{
dummy[i]=score[ptr1];
ptr1++;
}
else if(score[ptr1].prob==score[ptr2].prob)
{
if(score[ptr1].time<score[ptr2].time)
{
dummy[i]=score[ptr1];
ptr1++;
}
else
{
dummy[i]=score[ptr2];
ptr2++;
}
}
else
{
dummy[i]=score[ptr2];
ptr2++;
}
}
for(i=left,j=0;i<=right;i++,j++)
{
score[i]=dummy[j];
}
return;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.