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
sequencelengths 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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | f823fee174d069899b8321c32017f9bc | 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 sort(int a[][2],int n)
{int i,j,max,temp;
for(i=0;i<n;i++)
{max=i;
for(j=i+1;j<n;j++)
{
if(a[max][0]<a[j][0])
max=j;
else if(a[max][0]==a[j][0])
{
if(a[max][1]>a[j][1])
max=j;
}
}
// printf("%d ",max);
temp=a[max][0];
a[max][0]=a[i][0];
a[i][0]=temp;
temp=a[max][1];
a[max][1]=a[i][1];
a[i][1]=temp;
}
}
int main()
{int n,k,i,count;
count=0;
int a[51][2];
scanf("%d %d",&n,&k);
for(i=0;i<n;i++)
{
scanf("%d %d",&a[i][0],&a[i][1]);
}
sort(a,n);
for(i=k-1;i>=0;i--)
{
if(a[i][0]==a[k-1][0] && a[i][1]==a[k-1][1])
count++;
else
break;
}
for(i=k;i<n;i++)
{
if(a[i][0]==a[k-1][0] && a[i][1]==a[k-1][1])
count++;
else
break;
}
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 | a8f0874a7e04d80bd744b2e1f3a135e3 | 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 n,k,i,j,c=0,temp,p[50],t[50];
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
scanf("%d%d",&p[i],&t[i]);
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(p[i]<p[j] || (p[i]==p[j] && t[i]>t[j])){
temp=p[i];
p[i]=p[j];
p[j]=temp;
temp=t[i];
t[i]=t[j];
t[j]=temp;
}
}
}
for(i=0;i<n;i++){
if(p[i]==p[k-1] && t[i]==t[k-1])
c++;
}
printf("%d",c);
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 | c8d4c1f51103e72f7728720cda5c7423 | 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 num;
int time;
}team[60];
int cmp1(const void *a,const void *b)
{
struct Team *c=(struct Team*)a;
struct Team *d=(struct Team*)b;
if(c->num!=d->num)
return d->num-c->num;
else
return c->time-d->time;
}
int main()
{
int i,j,count,num,time;
int n,k;
while(scanf("%d %d",&n,&k)!=EOF)
{
for(i=0;i<n;i++)
scanf("%d %d",&team[i].num,&team[i].time);
qsort(team,n,sizeof(team[0]),cmp1);
i=j=k=k-1;
count=1;
time=team[k].time;
num=team[k].num;
while(i-1>=0&&team[i-1].num==num&&team[i-1].time==time)
{
i--;
count++;
}
while(j+1<n&&team[j+1].num==num&&team[j+1].time==time)
{
j++;
count++;
}
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 | 22193ff060dfbbddb854bad0e1937512 | 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 n,k,i,j,minin,temp1,temp2,count=1;
scanf ("%d%d",&n,&k);
int pro[n],time[n];
for (i=0;i<n;i++)
scanf ("%d%d",&pro[i],&time[i]);
for (i=0;i<n-1;i++)
{
minin=i;
for (j=i+1;j<n;j++)
{
if (pro[j]>pro[minin])
minin=j;
else if (pro[j]==pro[minin])
{
if (time[j]<=time[minin])
minin=j;
}
}
temp1=pro[i]; pro[i]=pro[minin]; pro[minin]=temp1;
temp2=time[i]; time[i]=time[minin]; time[minin]=temp2;
}
for (i=k;i<n;i++)
if ((pro[k-1]==pro[i])&&(time[k-1]==time[i]))
count++;
else
break;
for (i=k-2;i>=0;i--)
if ((pro[k-1]==pro[i])&&(time[k-1]==time[i]))
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 | 74fe01fad9a243efe0a895aea7fa18e5 | 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 tri(int tab[50][50],int n)
{int i,x,j,y,cont;
i=n-1;
cont=1;
while(cont==1)
{
j=0;
cont=0;
while(j<i)
{
if(tab[j][0]<tab[j+1][0])
{
y=tab[j][0];
tab[j][0]=tab[j+1][0];
tab[j+1][0]=y;
x=tab[j][1];
tab[j][1]=tab[j+1][1];
tab[j+1][1]=x;
cont=1;
}
if ((tab[j][0]==tab[j+1][0])&&(tab[j+1][1]<tab[j][1]))
{
y=tab[j][0];
tab[j][0]=tab[j+1][0];
tab[j+1][0]=y;
x=tab[j][1];
tab[j][1]=tab[j+1][1];
tab[j+1][1]=x;
cont=1;
}
j=j+1;
}
i=i-1;
}
}
int main()
{
int n,i,k,j;
int a;
int s=0;
scanf("%d",&n);
scanf("%d",&k);
int tab[50][50];
for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
{
scanf(" %d",&tab[i][j]);
}
}
tri(tab,n);
/* for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
{
printf(" %d",tab[i][j]);
}
}*/
for(i=0;i<n;i++)
{
if((tab[i][0]==tab[k-1][0])&&(tab[i][1]==tab[k-1][1]))
{
s=s+1;
}
}
printf("%d",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 | 5c1e155ee1e7cd277a7cac5a3ff5fcda | 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 sort(int p[],int t[],int n)
{
int key1,key2,i,j;
for(i=2;i<=n;i++)
{
key1=p[i],key2=t[i];
for(j=i-1;j>=1 && p[j]<=key1;j--)
{
if(p[j]==key1)
{
if(t[j]<=key2)
break;
p[j+1]=p[j];
t[j+1]=t[j];
}
else
{
p[j+1]=p[j];
t[j+1]=t[j];
}
}//innerfor
p[j+1]=key1;
t[j+1]=key2;
}//outerfor
}//func
int main()
{
int n,k;
int p[55];
int t[55];
int i,r,j;
scanf("%d",&n);
scanf("%d",&k);
i=1;
while(i<=n)
{
scanf("%d",&p[i]);
scanf("%d",&t[i]);
i++;
}
sort(p,t,n);
r=0;
for(i=1;i<=n;i++)
{
r++;
if(r==k)
break;
}
if(r<k)
{
printf("0");
return 0;
}
else
{
int count=1;
for(j=i-1;j>=1;j--)
{
if(p[j]!=p[i]||t[j]!=t[i])
break;
count++;
}
for(j=i+1;j<=n;j++)
{
if(p[j]!=p[i]||t[j]!=t[i])
break;
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 | d493c9dec693c90320ef8840ec25664f | 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 sort(int d[],int n);
void merge(int d[],int x[],int y[],int l,int r);
int main()
{
int n,k;
scanf("%d %d",&n,&k);
int score[n+1],i,p,t;
for(i=0;i<n;i++)
{
scanf("%d %d",&p,&t);
score[i]= 100*p - t;
}
sort(score,n);
int cnt=0,key=score[k-1];
for(i=0;i<n;i++)
{
if(score[i]==key)
cnt++;
}
printf("%d",cnt);
return 0;
}
void sort(int d[],int n)
{
if(n==1)
return;
int i,j;
int x[(n+1)/2],y[n-(n+1)/2];
for(i=0;i<(n+1)/2;i++)
x[i]=d[i];
for(i=(n+1)/2,j=0;i<n;i++,j++)
y[j]=d[i];
sort(x,(n+1)/2);
sort(y,j);
merge(d,x,y,((n+1)/2),j);
}
void merge(int d[],int x[],int y[],int l,int r)
{
//printf("%d %d \n",l,r);
int i=0,j=0,k=0;
for(;i<l && j<r;k++)
{
if(x[i]>=y[j])
{
d[k]=x[i];
i++;
}
else
{
d[k]=y[j];
j++;
}
}
while(i<l)
{
d[k]=x[i];
i++;
k++;
}
while(j<r)
{
d[k]=y[j];
j++;
k++;
}
} | |
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 | 89cc43b29d7ee3da6dc7a8a3658517ce | 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 data
{
int sol;
int pan;
};
typedef struct data data;
void setVal(data *t1, data *t2)
{
t1->sol = t2->sol;
t1->pan = t2->pan;
}
void merge(data dm[], int low, int mid, int high)
{
int i = low;
int j = mid+1;
data temp[high];
int k = 0;
while(i<=mid && j<=high)
{
if(dm[i].sol>dm[j].sol || (dm[i].sol == dm[j].sol && dm[i].pan<dm[j].pan))
{
setVal(&temp[k], &dm[i]);
i++, k++;
}
else
{
setVal(&temp[k], &dm[j]);
j++, k++;
}
}
while(i<=mid)
{
setVal(&temp[k], &dm[i]);
i++, k++;
}
while(j<=high)
{
setVal(&temp[k], &dm[j]);
j++, k++;
}
k = 0;
for(i=low; i<=high; i++)
{
setVal(&dm[i], &temp[k]);
k++;
}
}
void sort(data dm[], int low, int high)
{
if(low<high)
{
int mid = low+(high-low)/2;
sort(dm, low, mid);
sort(dm, mid+1, high);
merge(dm, low, mid, high);
}
}
int main()
{
int n, k;
scanf("%d%d", &n, &k);
int i;
data dm[n];
for(i=0; i<n; i++)
{
scanf("%d%d", &dm[i].sol, &dm[i].pan);
}
sort(dm, 0, n-1);
k--;
int count = 1;
i = k-1;
while(i>=0)
{
if(dm[i].sol == dm[k].sol && dm[i].pan == dm[k].pan)
count++;
else
break;
i--;
}
i = k+1;
while(k<n)
{
if(dm[i].sol == dm[k].sol && dm[i].pan == dm[k].pan)
count++;
else
break;
i++;
}
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 | 6518b21cef9df49a84dabb5ef09b5f24 | 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 n , k, p[51] , t[51] , i , j ,ket , s, f , a[51] , c ;
int main()
{
scanf("%d %d" , &n, &k) ;
for( i = 0 ; i < n ; i++)
{
scanf("%d %d" , &p[i] , &t[i] ) ;
}
for( j = 0 ; j < n ;j++ )
{
for( i = 1 ;i< n-j ; i++)
{
if( p[i] > p[i-1] )
{
ket = p[i] ;
p[i] = p[i-1] ;
p[i-1] = ket ;
ket = t[i] ;
t[i] = t[i-1] ;
t [i-1] = ket ;
}
else if ( p[i] == p[i-1] && t[i] < t[i-1] )
{
ket = p[i] ;
p[i] = p[i-1] ;
p[i-1] = ket ;
ket = t[i] ;
t[i] = t[i-1] ;
t [i-1] = ket ;
}
}
}
/* printf("\n") ;
for( i = 0 ; i < n ; i++ )
{
printf("%d %d\n", p[i] , t[i] ) ;
}*/
s = 0 ;
f = 0 ;
c= 1 ;
for( i = 1 ;i <= n;i++)
{
if( p[i] == p[i-1] && t[i] == t[i-1] )
{
c++ ;
// printf("when i = %d , c = %d,\n", i,c ) ;
}
else
{
// printf("b4 loop when f= %d, i = %d , c = %d, s = %d,\n", f, i,c, s ) ;
f = i ;
for( j = s ; j < f;j++)
{
a[j] = c ;
}
s = f ;
c = 1 ;
//printf("after loop when f= %d, i = %d , c = %d, s = %d,\n", f, i,c, s ) ;
}
}
/* printf("\n") ;
for( i = 0 ; i < n ; i++ )
{
printf("%d %d %d\n", p[i] , t[i], a[i] ) ;
}
printf("\n") ;*/
printf("%d", a[k-1] ) ;
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 | 1cf34f67f63d5302f8476d2c9d284447 | 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"] | /*
* a_rank_list.c
*
* Copyright 2012 Ygor Amaral <ygor@spider>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int numLinhas, qntEquipes; //n
int k; //posicao/place
scanf("%d %d", &numLinhas, &k);
qntEquipes = numLinhas;
int equipes[qntEquipes][2];
int i = 0;
while(numLinhas-- > 0) {
int questoes;
int penalidade;
scanf("%d %d", &questoes, &penalidade);
equipes[i][1] = questoes;
equipes[i][2] = penalidade;
i++;
}
int registrosMemoria = 0;
int memoria[qntEquipes][3];
//varrer as equipes
for(i = 0; i < qntEquipes; i++) {
//varrer a memoria, para saber se a equipe que vai ser analisada agora, é igual a alguma já analisada antes
int flagMemoria = 0; //false
int j;
for(j = 0; j < registrosMemoria; j++) {
if(equipes[i][1] == memoria[j][1] && equipes[i][2] == memoria[j][2]) {
flagMemoria = 1; //true
memoria[j][3]++;
break;
}
}
//se não estiver na memoria, guardar...
if(!flagMemoria) {
memoria[registrosMemoria][1] = equipes[i][1];
memoria[registrosMemoria][2] = equipes[i][2];
memoria[registrosMemoria][3] = 1;
registrosMemoria++;
}
}
int parar = 0;
while(!parar) {
parar = 1;
for(i = 0; i < registrosMemoria-1; i++) {
if((memoria[i][1] < memoria[i+1][1]) || (memoria[i][1] == memoria[i+1][1] && memoria[i][2] > memoria[i+1][2])) {
parar = 0;
int aux[3];
aux[1] = memoria[i][1];
aux[2] = memoria[i][2];
aux[3] = memoria[i][3];
memoria[i][1] = memoria[i+1][1];
memoria[i][2] = memoria[i+1][2];
memoria[i][3] = memoria[i+1][3];
memoria[i+1][1] = aux[1];
memoria[i+1][2] = aux[2];
memoria[i+1][3] = aux[3];
}
}
}
int w;
int tempEquipes = 0;
for(w = 0; w < registrosMemoria; w++) {
tempEquipes += memoria[w][3];
if(tempEquipes >= k) {
printf("%d", memoria[w][3]);
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 | 1f06fe61fd7ef48d10847c2e5362bb3c | 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"] | /*
* a_rank_list.c
*
* Copyright 2012 Ygor Amaral <ygor@spider>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int numLinhas, qntEquipes; //n
int k; //posicao/place
scanf("%d %d", &numLinhas, &k);
qntEquipes = numLinhas;
int equipes[qntEquipes][2];
int i = 0;
while(numLinhas-- > 0) {
int questoes;
int penalidade;
scanf("%d %d", &questoes, &penalidade);
equipes[i][1] = questoes;
equipes[i][2] = penalidade;
i++;
}
int registrosMemoria = 0;
int memoria[qntEquipes][3];
//varrer as equipes
for(i = 0; i < qntEquipes; i++) {
//varrer a memoria, para saber se a equipe que vai ser analisada agora, é igual a alguma já analisada antes
int flagMemoria = 0; //false
int j;
for(j = 0; j < registrosMemoria; j++) {
if(equipes[i][1] == memoria[j][1] && equipes[i][2] == memoria[j][2]) {
flagMemoria = 1; //true
memoria[j][3]++;
break;
}
}
//se não estiver na memoria, guardar...
if(!flagMemoria) {
memoria[registrosMemoria][1] = equipes[i][1];
memoria[registrosMemoria][2] = equipes[i][2];
memoria[registrosMemoria][3] = 1;
registrosMemoria++;
}
}
int parar = 0;
while(!parar) {
parar = 1;
for(i = 0; i < registrosMemoria-1; i++) {
if((memoria[i][1] < memoria[i+1][1]) || (memoria[i][1] == memoria[i+1][1] && memoria[i][2] > memoria[i+1][2])) {
parar = 0;
int aux[3];
aux[1] = memoria[i][1];
aux[2] = memoria[i][2];
aux[3] = memoria[i][3];
memoria[i][1] = memoria[i+1][1];
memoria[i][2] = memoria[i+1][2];
memoria[i][3] = memoria[i+1][3];
memoria[i+1][1] = aux[1];
memoria[i+1][2] = aux[2];
memoria[i+1][3] = aux[3];
}
}
}
int w;
int tempEquipes = 0;
for(w = 0; w < registrosMemoria; w++) {
tempEquipes += memoria[w][3];
if(tempEquipes >= k) {
printf("%d", memoria[w][3]);
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 | d9a0ef01b601c7f51827f6de0b520253 | 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(void)
{
int n,k,i,j,m,y,a=0;
int t[51],p[51];
scanf("%d %d",&n,&k);
for(i=0;i<n;i++)
scanf("%d %d",&p[i],&t[i]);
for(i=1;i<n;++i){
for(j=n-1;j>=i;--j){
if(p[j-1]<p[j]) {
m=p[j-1];
p[j-1]=p[j];
p[j]=m;
y=t[j-1];
t[j-1]=t[j];
t[j]=y;
}
if(p[j]==p[j-1]&&t[j-1]>t[j]) {
y=t[j-1];
t[j-1]=t[j];
t[j]=y;
}
}
}
for(i=0;i<n;i++)
{
if(p[i]==p[k-1]&&t[i]==t[k-1]) a++;
}
printf("%d",a);
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 | cc0b2f11c652bc19e005d0e83193f8a2 | 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>
long long p[6000];
int cmp (const void * a, const void * b)
{
return ( -*(int*)a + *(int*)b );
}
void main(){
long long n,k,i,a,b;
scanf("%lld %lld",&n,&k);
long long c[n];
for(i=0;i<n;i++){
scanf("%lld %lld",&a,&b);
c[i]=a*100-b;
p[c[i]]++;}
qsort(c,n,sizeof(long long),cmp);
printf("%lld\n",p[c[k-1]]);
exit(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 | c597e59ce0e430128e0decc793fa69c7 | 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<limits.h>
struct friend{
int pr;
int pl;
};
void mergeSort(struct friend *,int,int);
void merge(struct friend *,int,int,int);
int main(){
int i,n,d,j;
scanf("%d%d",&n,&d);
struct friend ar[n],ptr;
for(i=0;i<n;i++){
scanf("%d%d",&ar[i].pr,&ar[i].pl);
}
//mergeSort(ar,0,n-1);
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(ar[i].pr < ar[j].pr || (ar[i].pr == ar[j].pr && ar[i].pl >= ar[j].pl)){
struct friend tmp;
tmp.pr = ar[i].pr;
tmp.pl = ar[i].pl;
ar[i].pr = ar[j].pr;
ar[i].pl = ar[j].pl;
ar[j].pr = tmp.pr;
ar[j].pl = tmp.pl;
}
}
}
int key1 = ar[d-1].pr;
int key2 = ar[d-1].pl;
int count = 0;
for(i=0;i<n;i++){
//printf("%d %d \n",ar[i].pr,ar[i].pl);
if(ar[i].pr == key1 && ar[i].pl == key2){
count++;
}
}
printf("%d",count);
}
void merge(struct friend *arr, int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
struct friend L[n1], R[n2];
for (i = 0; i < n1; i++){
L[i].pr = (arr + l + i)->pr;
L[i].pl = (arr + l + i)->pl;
}
for (j = 0; j < n2; j++){
R[j].pr = (arr + m + 1+ j)->pr;
R[j].pl = (arr + m + 1 +j)->pl;
}
i = 0; // Initial index of first subarray
j = 0; // Initial index of second subarray
k = l; // Initial index of merged subarray
while (i < n1 && j < n2)
{
if (L[i].pr > R[j].pr || (L[i].pr == R[i].pr && L[i].pl < R[i].pl))
{
(arr+k)->pr = L[i].pr;
(arr+k)->pl = L[i].pl;
i++;
}
else
{
(arr+k)->pr = R[j].pr;
(arr+k)->pl = R[j].pl;
j++;
}
k++;
}
while (i < n1)
{
(arr+k)->pr = L[i].pr;
(arr+k)->pl = L[i].pl;
i++;
k++;
}
while (j < n2)
{
(arr+k)->pr = R[j].pr;
(arr+k)->pl = R[j].pl;
j++;
k++;
}
}
void mergeSort(struct friend *arr, int l, int r)
{
if (l < r)
{
int m = l+(r-l)/2;
mergeSort(arr, l, m);
mergeSort(arr, m+1, r);
merge(arr, l, m, r);
}
}
| |
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 | f1ee80a51403d1a5d4346ac75d409106 | 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>
typedef struct {
int p,t;
}Rank;
int cmp ( const void *x, const void *y ) {
const Rank *a = (const Rank *)x;
const Rank *b = (const Rank *)y;
if( a->p != b->p )
return b->p - a->p;
else
return a->t - b->t;
}
int main()
{
Rank a[51];
int n, k, i, j = 0, c, b;
scanf("%d%d", &n, &k);
for( i = 0; i < n; i++)
scanf("%d%d", &a[i].p, &a[i].t );
qsort( a, n, sizeof( Rank ), cmp );
c = a[k-1].p;
b = a[k-1].t;
for( i = 0; i < n; i++ ){
if( a[i].p == c && a[i].t == b )
j++;
}
printf("%d\n", j);
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 | f27bba8ea210d0fef44a919eb6ce9cdd | 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 i,j,n,k,a[50][2],m=0,p,t,t1,c=0;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++){
scanf("%d%d",&a[i][0],&a[i][1]);
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(a[j][0]>a[i][0] || (a[j][0]==a[i][0] && a[j][1]<a[i][1])){
t=a[i][0]; t1=a[i][1];
a[i][0]=a[j][0]; a[i][1]=a[j][1];
a[j][0]=t; a[j][1]=t1;
}
}
}
for(i=0;i<n;i++){
if(a[i][0]==a[k-1][0] && a[i][1]==a[k-1][1])c++;
}
/* for(i=0;i<n;i++){
printf("%d %d\n",a[i][0],a[i][1]);
} */
printf("%d",c);
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 | eac276e2f393a4ef9d655935403b013d | 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<string.h>
int a[100],b[100];
int main()
{
int n,m,i,j,count,t;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(i=0; i<n; i++)
{
scanf("%d%d",&a[i],&b[i]);
}
for(i=0; i<n-1; i++)
{
for(j=i+1; j<n; j++)
{
if(a[i]<a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
t=b[i];
b[i]=b[j];
b[j]=t;
}
else if(a[i]==a[j])
{
if(b[i]>b[j])
{
t=b[i];
b[i]=b[j];
b[j]=t;
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
}
count=0;
for(i=0; i<n; i++)
{
if(a[m-1]==a[i]&&b[m-1]==b[i])
count++;
}
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 | 5b3a31f2cdf210ec659a73fa04acc81c | 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>
struct point
{
int p;
int t;
};
void swap(int i ,int j,struct point a[])
{
int x, y;
x=a[i].p;
a[i].p=a[j].p;
a[j].p=x;
y=a[i].t;
a[i].t=a[j].t;
a[j].t=y;
}
int partition (struct point a[],int low,int high)
{
// pivot (Element to be placed at right position)
int pivoti = high;
int i = (low - 1); // Index of smaller element
for (int j = low; j <= high- 1; j++)
{
// If current element is smaller than or
// equal to pivot
if (a[j].p<a[pivoti].p||((a[j].p)==a[pivoti].p&&a[j].t>=a[pivoti].t))
{
i++; // increment index of smaller element
swap(i ,j,a);
}
}
swap (i+1 ,high,a);
return (i + 1);
}
void quickSort(struct point arr[],int low,int high)
{
if (low < high)
{
/* pi is partitioning index, arr[p] is now
at right place */
int pi = partition(arr, low, high);
quickSort(arr, low, pi - 1); // Before pi
quickSort(arr, pi + 1, high); // After pi
}
}
int binary1(struct point a[],int low,int high,int index)
{
int best;
while(low<=high)
{
int mid=(low+high)/2;
if(a[mid].p==a[index].p&&a[mid].t==a[index].t)
{
best=mid;
high=mid-1;
}
else
low=mid+1;
}
return best;
}
int binary2(struct point a[],int low,int high,int index)
{
int best;
while(low<=high)
{
int mid=(low+high)/2;
if(a[mid].p==a[index].p&&a[mid].t==a[index].t)
{
best=mid;
low=mid+1;
}
else
high=mid-1;
}
return best;
}
int main()
{
int n,k;
struct point a[200],b[200];
scanf("%d %d",&n,&k);
for(int i=0;i<n;i++)
{
scanf("%d %d",&a[i].p,&a[i].t);
}
quickSort(a,0,n-1);
for(int i=0;i<n;i++)
{
b[n-1-i].p=a[i].p;
b[n-1-i].t=a[i].t;
}
//for(int i=0;i<n;i++)
//printf("%d %d\n",b[i].p,b[i].t);
int x,y;
x=binary1(b,0,k-1,k-1);
y=binary2(b,k-1,n-1,k-1);
printf("%d",y-x+1);
} | |
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 | 3500eb35a556add62d366080124a6e4c | 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"] | //Rank List
#include<stdio.h>
int main(){
int i , n , c=0 , k , temp , j ;
scanf("%d%d",&n,&k);
int a[n] , b[n];
for(i=0;i<n;i++)
{
scanf("%d%d",&a[i],&b[i]);
}
//printf("\n");
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]<a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
temp = b[i];
b[i] = b[j];
b[j] = temp;
}
}
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]==a[j] && b[i]>b[j])
{
temp = b[i];
b[i] = b[j];
b[j] = temp;
}
}
}
/*
for(i=0;i<n;i++)
{
printf("%d %d\n",a[i],b[i]);
}
*/
//printf("%d %d",a[k-1],b[k-1]);
for(i=0;i<n;i++)
{
if(a[i]==a[k-1] && b[i]==b[k-1])
{
//printf("%d ",i);
c++;
}
}
printf("%d",c);
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 | fae804a9666684f45dff2bed25ee1cf8 | 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>
typedef struct cont {
int p, t;
} cont_t;
int s(const void *a, const void *b) {
cont_t *ca = (cont_t*)a, *cb = (cont_t*)b;
if(ca->p != cb->p) {
if(ca->p > cb->p) return -1;
else return 1;
}
if(ca->t < cb->t) return -1;
else if(ca->t == cb->t) return 0;
else return 1;
}
int main() {
int n, k, i, tot;
cont_t *arr;
scanf("%d %d", &n, &k);
arr = malloc(n*sizeof(cont_t));
for(i=0; i<n; ++i) {
scanf("%d %d", &arr[i].p, &arr[i].t);
}
qsort(arr, n, sizeof(cont_t), s);
for(i=0, tot=0; i<n; ++i) {
if(s(&arr[i], &arr[k-1]) == 0) ++tot;
}
printf("%d", tot);
free(arr);
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 | 3cd3d49a0c4c01614845a7fdf7eabd13 | 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 a[10000][2];
int main ()
{
int i,i2,c,d,counter,temp;
counter=0;
scanf ("%d %d",&i,&c);
d=i;
temp=i;
for(;i>0;i--)
{
scanf("%d %d",&a[d-i][0],&a[d-i][1]);
}
for(;d>0;d--)
{
for (i=0;i<d;i++)
{
if (a[i][0]<a[i+1][0]||(a[i][0]==a[i+1][0]&&a[i][1]>a[i+1][1]))
{
a[i][0]+=a[i+1][0];
a[i+1][0]=a[i][0]-a[i+1][0];
a[i][0]-=a[i+1][0];
a[i][1]+=a[i+1][1];
a[i+1][1]=a[i][1]-a[i+1][1];
a[i][1]-=a[i+1][1];
}
}
}
for (i = 0; i < temp; i++)
{
if (a[c-1][0] == a[i][0] && a[c-1][1] == a[i][1])counter++;
}
/*for(i=c+1;i<temp;i++)
{
if(a[c][0]==a[i][0]&&a[c][1]==a[i][1]) counter++;
}
for(i=c-1;i>-1;i--)
{
if(a[c][0]==a[i][0]&&a[c][1]==a[i][1]) 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 | 6090e1aea519238e9d632fd745932b24 | 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 p;
int t;
};
int compare(const void *a,const void *b)
{
if(((struct team *)b)->p == ((struct team *)a)->p)
{
return ((struct team *)a)->t - ((struct team *)b)->t;
}
return ((struct team *)b)->p - ((struct team *)a)->p ;
}
int main()
{
int n ,k;
scanf("%d%d",&n,&k);
struct team teams[n];
int i;
for(i=0;i<n;i++)
scanf("%d%d",&teams[i].p,&teams[i].t);
qsort(teams,n,sizeof(teams[0]),compare);
// for(i=0;i<n;i++)
// printf("%d %d\n",teams[i].p,teams[i].t);
int ans=1;
i=k-1+1;
while(teams[k-1].p==teams[i].p&&teams[k-1].t==teams[i].t)
{
ans++;
i++;
}
i=k-1-1;
while(teams[k-1].p==teams[i].p&&teams[k-1].t==teams[i].t)
{
ans++;
i--;
}
printf("%d",ans);
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 | 475c6116258c58856b45fde4d20e0bca | 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 n,k,i,p,t,j,c;
double m;
double ara[55];
int a[55];
scanf("%d%d",&n,&k);
for(i=0;i<n;i++) {
scanf("%d %d",&p,&t);
m=p-t/100.0;
ara[i]=m;
}
for(i=0;i<n-1;i++) {
for(j=i+1;j<n;j++) {
if(ara[i]<ara[j]) {
m=ara[i];
ara[i]=ara[j];
ara[j]=m;
}
}
}
/*for(i=0;i<n;i++) {
printf("%lf\n",ara[i]);
}*/
ara[n]=0.0;
m=ara[0];
c=1;
for(i=1;i<=n;i++) {
if(ara[i]==m) {
c++;
}
else {
m=ara[i];
for(j=i-1;j>=i-c;j--) {
a[j]=c;
}
c=1;
}
}
/*for(i=0;i<n;i++) {
printf("%d\n",a[i]);
}*/
printf("%d\n",a[k-1]);
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 | 0f17583a7477542779ff71927565b3b0 | 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 sz 200
int p[sz],t[sz];
int main()
{
int i,j,k,l,n,tp,tt,count,sp,st,tp2,tt2;
while(scanf("%d %d",&n,&k)!=EOF)
{
count=0;
for(i=1;i<=n;i++)
{
scanf("%d %d",&p[i],&t[i]);
}
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
if(p[i]<p[j])
{
tp=p[i];
p[i]=p[j];
p[j]=tp;
tt=t[i];
t[i]=t[j];
t[j]=tt;
}
else if(p[i]==p[j])
{
if(t[i]>t[j])
{
tt2=t[i];
t[i]=t[j];
t[j]=tt2;
tp2=p[i];
p[i]=p[j];
p[j]=tp2;
}
}
}
}
sp=p[k];
st=t[k];
for(i=1;i<=n;i++)
{
if(sp==p[i]&&st==t[i]){
count++;
}
}
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 | 05fad448607317974b9a7690e591beb3 | 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"] | #pragma warning(disable:4996)
#pragma comment(linker, "/STACK:16777216")
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define PI 3.1415926535897932384
#ifndef ONLINE_JUDGE
FILE *stream;
#endif
typedef struct{
int p;
int t;
} teamResult;
int CmpTeamResult(const void *team1, const void *team2){
int diff;
diff = ((teamResult*)team1)->p - ((teamResult*)team2)->p;
if (diff == 0){
diff = ((teamResult*)team2)->t - ((teamResult*)team1)->t;
return -diff;
}
else
return -diff;
}
int main()
{
teamResult arr[50];
int n, k;
int i;
int result;
#ifndef ONLINE_JUDGE
freopen_s(&stream, "D:\\Work\\CodeForces\\input.txt", "rt", stdin);
freopen_s(&stream, "D:\\Work\\CodeForces\\output.txt", "wt", stdout);
#endif
scanf("%i%i", &n, &k);
for (i = 0; i < n; i++)
scanf("%i%i", &arr[i].p, &arr[i].t);
qsort(arr, n, sizeof(teamResult), CmpTeamResult);
result = 1;
for (i = k-2; (i >= 0) && (arr[i].p == arr[k-1].p) && (arr[i].t == arr[k-1].t); i--)
result++;
for (i = k; (i < n) && (arr[i].p == arr[k-1].p) && (arr[i].t == arr[k-1].t); i++)
result++;
printf("%i", result);
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 | 62f23625e0ed7ad5bf9a664527bb6c8f | 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 <conio.h>
int main()
{
int n,k,i,j,d,a,b,c,x,y,count,swap,swap1,swap2,swap3;
scanf("%d%d", &n, &k);
int p[n], t[n];
for(i = 0; i < n; i++){
scanf("%d", &p[i]);
scanf("%d", &t[i]);
}
for(j = 0; j < n; j++){
for(d = 0; d < (n-j)-1; d++){
if(p[d] < p[d+1]){
swap = p[d];
p[d] = p[d+1];
p[d+1] = swap;
swap1 = t[d];
t[d] = t[d+1];
t[d+1] = swap1;
}
}
}
for(b = 0; b < n; b++){
for(a = 0; a < (n-b)-1; a++){
if(p[a]==p[a+1]){
if(t[a]> t[a+1]){
swap2 = t[a];
t[a] = t[a+1];
t[a+1] = swap2;
swap3 = p[a];
p[a] = p[a+1];
p[a+1] = swap3;
}
}
}
}
x = p[k-1];
y = t[k-1];
count = 0;
for(c = 0; c < n; c++){
if(p[c]==x && t[c]==y){
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 | c698944f3a8207980df92dce3c15e710 | 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 n,k,i,j,m,l,c=1,t,t1;
scanf("%d %d",&n,&k);
int a[n],b[n];
for(i=0;i<n;i++)
scanf("%d %d",&a[i],&b[i]);
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
if(a[i]<a[j])
{
t=a[j];
a[j]=a[i];
a[i]=t;
t1=b[j];
b[j]=b[i];
b[i]=t1;
}
else if(a[i]==a[j])
{
if(b[i]>b[j])
{
t=b[j];
b[j]=b[i];
b[i]=t;
}
}
}
}
m=a[0]; l=b[0];
for(i=1;i<n;i++)
{
if(m==a[i] && l==b[i])
c++;
else
{
k=k-c;
if(k<=0)
{
printf("%d",c);
return 0;
}
c=1;
m=a[i]; l=b[i];
}
}
printf("%d",c);
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 | 05fa1f6e8116aeca2e95205f2d2e5104 | 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 <conio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int main (void){
int n,k,i,x,j,temp,counter=0,s;
scanf("%d %d",&n,&k);
int p[n],t[n];
for(i=0;i<n;i++){
scanf("%d %d",&p[i],&t[i]);
}
for(i=0;i<n;i++){
x=i;
for(j=i+1;j<n;j++){
if(p[j]>p[x]){
x=j;
}
else if (p[j]==p[x]){
if(t[j]<t[x])
x=j;
}
}
temp=p[i];
p[i]=p[x];
p[x]=temp;
temp=t[i];
t[i]=t[x];
t[x]=temp;
}
temp = p[k-1];
s=t[k-1];
for(i=0;i<n;i++){
if(p[i] == temp && t[i]==s)
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 | 71f18255c161bbba6c13c08f8816e1ac | 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 N 50
int main() {
//Your task is to count what number of teams from the given list shared the k-th place.
//(1 ≤ k ≤ n ≤ 50).
int n,k;
scanf("%d%d",&n,&k);
//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.
int p[N],t[N];
int i;
for(i=0;i<n;i++){
scanf("%d%d",&p[i],&t[i]);
}
//先排序,之后查看k位置的向后有多少相同项目!
int j;
for(i=0;i<n-1;i++) {
int max=i;
for(j=i+1;j<n;j++) {
if(p[j]>p[max]){
max=j;
}else if(p[j]==p[max] && t[j]<t[max]) {
max=j;
}
}
int tmp=p[i];
p[i]=p[max];
p[max]=tmp;
tmp=t[i];
t[i]=t[max];
t[max]=tmp;
}
/*
for(i=0;i<n;i++) {
printf(" (%d,%d)",p[i],t[i]);
}
printf("\n");
*/
int count=1;
k--;//让k从零开始计数!
for(i=k+1;i<n;i++) {
if(p[i]==p[k] && t[i]==t[k]) count++;
else break;
}
for(i=k-1;i>=0;i--) {
if(p[i]==p[k] && t[i]==t[k]) 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 | 00a5345fd6de04113da54b3d34ed490c | 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>
struct contest
{
int p,t;
} team[60];
main()
{
int n,k,i,j,x,y,temp1,temp2,key,time,count;
scanf("%d %d",&n,&k);
for(i=0; i<n; i++)
{
scanf("%d %d",&team[i].p,&team[i].t);
}
for(i=0; i<n; i++) //sorting out only team solves
{
for(j=0; j<n-1; j++)
{
if(team[j].p<team[j+1].p)
{
temp1=team[j+1].p;
temp2=team[j+1].t;
team[j+1].p=team[j].p;
team[j+1].t=team[j].t;
team[j].p=temp1;
team[j].t=temp2;
}
}
}
for(i=0; i<n; i++)
{
for(j=0; j<n-1; j++) //sorting time according to team solves
{
if((team[j].p==team[j+1].p)&&(team[j].t>team[j+1].t))
{
temp1=team[j+1].p;
temp2=team[j+1].t;
team[j+1].p=team[j].p;
team[j+1].t=team[j].t;
team[j].p=temp1;
team[j].t=temp2;
}
}
}
key=team[k-1].p;
time=team[k-1].t;
count=0;
for(x=0; x<n; x++)
{
while((team[x].p==key)&&(team[x].t==time))
{
count++;
x++;
}
}
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 | 10e75178aeb895c5a80e41efdbfbc935 | 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>
struct contest
{
int p,t;
} team[60];
main()
{
int n,k,i,j,x,y,temp1,temp2,key,time,count;
scanf("%d %d",&n,&k);
for(i=0; i<n; i++)
{
scanf("%d %d",&team[i].p,&team[i].t);
}
for(i=0; i<n; i++) //sorting out only team solves
{
for(j=0; j<n-1; j++)
{
if(team[j].p<team[j+1].p)
{
temp1=team[j+1].p;
temp2=team[j+1].t;
team[j+1].p=team[j].p;
team[j+1].t=team[j].t;
team[j].p=temp1;
team[j].t=temp2;
}
}
}
for(i=0; i<n; i++)
{
for(j=0; j<n-1; j++) //sorting time according to team solves
{
if((team[j].p==team[j+1].p)&&(team[j].t>team[j+1].t))
{
temp1=team[j+1].p;
temp2=team[j+1].t;
team[j+1].p=team[j].p;
team[j+1].t=team[j].t;
team[j].p=temp1;
team[j].t=temp2;
}
}
}
key=team[k-1].p;
time=team[k-1].t;
count=0;
for(x=0; x<n; x++)
{
while((team[x].p==key)&&(team[x].t==time))
{
count++;
x++;
}
}
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 | df314e18af8bc2097f4d870aa5be8fc2 | 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<limits.h>
int main()
{
int n,k,i,maxh=0,j,s=0;
scanf("%d %d",&n,&k);
int dizi[n][2];
int sorted[n][2];
for (i=0;i<n;i++)
scanf(" %d %d",&dizi[i][0],&dizi[i][1]);
for (j=0;j<n;j++)
{
for (i=0;i<n;i++)
{
if (dizi[i][0]>dizi[maxh][0])
maxh=i;
else if (dizi[i][0]==dizi[maxh][0]&&dizi[i][1]<dizi[maxh][1])
maxh=i;
}
sorted[j][0]=dizi[maxh][0];
sorted[j][1]=dizi[maxh][1];
dizi[maxh][0]=INT_MIN;
dizi[maxh][1]=INT_MAX;
}
for (i=k-2;i>=0;i--)
{
if (sorted[k-1][0]==sorted[i][0]&&sorted[k-1][1]==sorted[i][1])
s++;
else
break;
}
for (i=k;k<n;i++)
{
if (sorted[k-1][0]==sorted[i][0]&&sorted[k-1][1]==sorted[i][1])
s++;
else
break;
}
printf("%d",s+1);
return 0;
}
| |
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ≤ l ≤ |s|) is string s[|s| - l + 1..|s|]. Your task is, for any prefix of string s which matches a suffix of string s, print the number of times it occurs in string s as a substring. | In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in the order of increasing li. | C | 3fb70a77e4de4851ed93f988140df221 | b9a3f7e4859967f89ecf1d2897096def | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"string suffix structures",
"strings"
] | 1400167800 | ["ABACABA", "AAA"] | null | PASSED | 2,000 | standard input | 1 second | The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters. | ["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"] | #include<stdio.h>
#include<string.h>
#include<math.h>
#define MAXN 100005
int next[MAXN],exkmp[MAXN];
char str[MAXN];
int sum[MAXN];
int m;
int a[MAXN],b[MAXN];
int min(int x,int y) { return x<y?x:y; }
int main(){
scanf("%s",str);
int n=strlen(str),i,k;
for (i=1,k=0; i<n; ++i){
int p=0;
if (k+next[k]-1>=i) p=min(k+next[k]-i,next[i-k]);
//printf("%d %d\n",i,p);
while (i+p<n && str[i+p]==str[p]) ++p;
next[i]=p;
if (i+p>k+next[k]) k=i;
}
next[0]=n;
for (i=0; i<n; ++i) ++sum[next[i]];
for (i=n-1; i>=0; --i) sum[i]+=sum[i+1];
for (i=0,m=0; i<n; ++i)
if (next[n-i-1]>=i+1)
a[m]=i+1,b[m++]=sum[i+1];
printf("%d\n",m);
for (i=0; i<m; ++i) printf("%d %d\n",a[i],b[i]);
return 0;
}
| |
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj. The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l]. The suffix of string s of length l (1 ≤ l ≤ |s|) is string s[|s| - l + 1..|s|]. Your task is, for any prefix of string s which matches a suffix of string s, print the number of times it occurs in string s as a substring. | In the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers li ci. Numbers li ci mean that the prefix of the length li matches the suffix of length li and occurs in string s as a substring ci times. Print pairs li ci in the order of increasing li. | C | 3fb70a77e4de4851ed93f988140df221 | b4719d5807e71c70a69d7ee90a17117f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"two pointers",
"string suffix structures",
"strings"
] | 1400167800 | ["ABACABA", "AAA"] | null | PASSED | 2,000 | standard input | 1 second | The single line contains a sequence of characters s1s2...s|s| (1 ≤ |s| ≤ 105) — string s. The string only consists of uppercase English letters. | ["3\n1 4\n3 2\n7 1", "3\n1 3\n2 2\n3 1"] | /*
* 432D: Prefixes and Suffixes
* TOPIC: suffix automata
* status:
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define L(k) ((k) & ((~(k))+1ULL))
#define BIT(k) (1ULL<<(k))
#define MASK(k) (BIT(k)-1ULL)
#define TST(u,k) ((u)&BIT(k))
#define SET(u,k) ((u)|=BIT(k))
#define A 26
#define N (100000+7)
#define IS_PREFIX(x) ((x)->u & BIT(A))
#define IS_SUFFIX(x) ((x)->u & BIT(A+1))
#define is_primary(x,y) ((x)->len+1==(y)->len)
#define Q (N*3)
typedef struct cell {
struct cell *son[A],*slink;
unsigned int u;
int len, freq, count;
} cell;
char which[1<<20],s[N];
int who( unsigned int u ) { return u>=BIT(20)?20+which[u>>20]:which[u]; }
cell *ptr,pool[Q],*q[Q],**head,**tail,*sink,*root;
int cnt[N];
void add_son( cell *x, int ch, cell *y ) { SET(x->u,ch), x->son[ch] = y; }
cell *init( int len ) {
cell *x;
assert( ptr-pool < sizeof(pool)/sizeof *pool );
x = ptr++, x->len = len, x->u = x->freq = x->count = 0, x->slink = NULL;
return x;
}
cell *split( cell *x, int ch ) {
cell *y = x->son[ch], *z = init(x->len+1);
unsigned int u,i;
z->slink = y->slink, y->slink = z, ++z->count;
for ( u=z->u=(y->u&MASK(A)); u; i = who(L(u)), add_son(z,i,y->son[i]), u &= ~L(u) ) ;
for ( add_son(x,ch,z); (x=x->slink) && TST(x->u,ch) && x->son[ch] == y; add_son(x,ch,z) ) ;
return z;
}
cell *update( int ch ) {
cell *new_sink = init(sink->len+1), *x;
for (++new_sink->freq,SET(new_sink->u,A),add_son(x=sink,ch,new_sink); (x=x->slink) && !TST(x->u,ch); add_son(x,ch,new_sink) ) ;
new_sink->slink = (!x?root:is_primary(x,x->son[ch])?x->son[ch]:split(x,ch));
++new_sink->slink->count;
return new_sink;
}
int main() {
int i,j,k,n;
cell *x,*y;
for ( i = 0; i < 20; which[BIT(i)] = i, ++i ) ;
while ( 1 == scanf("%s",s+1) ) {
ptr = pool, root = sink = init(0);
for ( n = 1; s[n]; sink = update(s[n++]-'A') ) ;
for ( --n, head = tail = q, i = 0; i < ptr-pool; ++i )
if ( !pool[i].count ) *tail++ = pool+i;
for (;head<tail;)
if ( (y=(x=*head++)->slink) && !((y->freq+=x->freq),--y->count) && (*tail++=y) ) ;
for ( x=sink; x; SET(x->u,A+1),x=x->slink ) ;
for ( i = 0; i <= n; cnt[i++] = 0 ) ;
for ( k = 0, i = 0; i < ptr-pool; ++i )
if ( (x = pool+i)->len && (x->u>>A) == 3 )
cnt[x->len] = x->freq, ++k;
for ( printf("%d\n",k), i = 1; i <= n; ++i )
if ( cnt[i] )
printf("%d %d\n",i,cnt[i]);
}
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | bb3179ade15744d59c0ae9c92ad43ea4 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | # include <stdio.h>
int main()
{
int n,m,a,b,x[3003]={0},i,sum=0,s;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
x[a]+=b;
}
s=m;
for(i=0;i<3002;i++)
{
if(x[i]<=s){ sum+=x[i]; s=m; continue; }
sum+=s;
if(x[i]-s<=m){sum=sum+x[i]-s; s=m-x[i]+s; continue ;}
sum+=m; s=0;
}
printf("%d",sum);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 51833ccf52bf3e4cddb57ad4d62d7d49 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
int main(){
int a[3002],ripe[3002],cur=0,ans=0,day=0,rip=0,n=0,v=0,i=0;
for(i=0;i<3002;i++){
a[i]=0;
ripe[i]=0;
}
scanf("%d %d",&n,&v);
for(i=0;i<n;i++){
scanf("%d",&day);
scanf("%d",&rip);
ripe[day]=ripe[day]+rip;
}
for(i=0;i<3002;i++){
if(cur+ripe[i]<=v){
ans=ans+cur+ripe[i];
cur=0;
}
else if(cur+ripe[i]>v){
if(cur>=v){
ans=ans+v;
cur=ripe[i];
}
else {
ans=ans+v;
cur=cur+ripe[i]-v;
}
}
}
printf("%d\n",ans);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 59f09a5aa3289d3649acb31b614ea65c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
struct d{
int x,y;
} p[4000];
int comp(struct d *a,struct d*b){
if((*a).x-(*b).x>=0) return 1;
else return -1;
}
int main() {
int a,b,c,d,e,t,m,n,i,j,k,v,ans=0;
scanf("%d %d",&n,&v);
for(i=0;i<n;++i){
scanf("%d %d",&p[i].x,&p[i].y);
}
qsort(p,n,sizeof(struct d),comp);
a=0;b=v,i=1;
while(a<n){
b=v;
while(i>p[a].x+1&&a<n) a++;
while(b>0&&(i-p[a].x)>=0&&(i-p[a].x)<=1&&a<n){
if(b>=p[a].y){ans+=p[a].y; b-=p[a].y;p[a].y=0;a++;}
else {ans+=b;p[a].y-=b;b=0;}
}
i++;
}
printf("%d\n",ans);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 30f346c1c20cb20cc87e06ec05f70b0a | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | /* بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ */
/* رَّبِّ زِدْنِى عِلْمًا */
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int n,v,pre,rotting,a[4005],b[4005],i,j,bag,collect,day,v2;
while(scanf("%d%d",&n,&v)!=EOF)
{
day=0;
bag=0;
for(i=0;i<n;i++)
{
scanf("%d%d",&a[i],&b[i]);
if(a[i]>day)
day=a[i];
}
rotting=0;
day+=2;
for(i=1;i<day;i++)
{
pre=0;
for(j=0;j<n;j++)
{
if(a[j]==i)
{
pre+=b[j];
}
}
if(rotting>v)
{
bag+=v;
v2=0;
}
else
{
bag+=rotting;
v2=v-rotting;
}
if(pre>v2)
{
bag+=v2;
pre-=v2;
}
else
{
bag+=pre;
pre=0;
}
rotting=pre;
}
printf("%d\n",bag);
}
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 6ae1c6d0e36261a3cbf7e51a38adc6d1 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define MAX(x,y) (x)>(y) ? (x):(y)
#define MIN(x,y) (x)>(y) ? (y):(x)
#define scnn fscanf(stdin,"%i",&n)
#define scnnd fscanf(stdin,"%i %i",&n,&d)
#define scnmi fscanf(stdin,"%i",&m[i])
#define forn for(i=0;i<n;i++)
#define memmn m=(int *)malloc(n*sizeof(int))
#define fm free(m)
#define prntmn for(i=0;i<n;i++)fprintf(stdout,"%i ",m[i])
int cmpfunc (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main(int argc, char **argv)
{
int n,i,j,*m,d,sum,rest,TTMMPP,maxJ;
scnnd;
maxJ=0;
m=(int*)calloc(3000,sizeof(int));
forn
{
fscanf(stdin,"%i",&j);
fscanf(stdin,"%i",&TTMMPP);
if(j-1>maxJ) maxJ=j-1;
m[j-1]+=TTMMPP;
}
if (n==1) {sum=MIN(m[j-1],2*d); fprintf(stdout,"%i",sum);
return 0;}
sum=MIN(d,m[0]);
m[0]-=d;
for(i=1;i<maxJ+1;i++)
{
rest=d;
if (m[i-1]>0) {sum+=MIN(d,m[i-1]);rest-=MIN(d,m[i-1]);}
if (rest>0) {sum+=MIN(rest,m[i]); m[i]-=MIN(rest,m[i]);}
}
if (m[maxJ]>0) sum+=MIN(d,m[maxJ]);
fprintf(stdout,"%i",sum);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 46b05f4b9186620ad80261a3170ef10e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
int main(){
int i,a,b,c[3003][2]={0},d,e,ans=0,f;
scanf("%d %d",&a,&b);
while(a--)
{
scanf("%d %d",&d,&e);
c[d][0]+=e;
}
for(i=1;i<3002;i++)
{
if(c[i][1]<=b)
{
ans+=c[i][1];
f=b-c[i][1];
if(c[i][0]<=f)ans+=c[i][0];
else {ans+=f;c[i+1][1]=c[i][0]-f;}
}
else
{ans+=b;c[i+1][1]=c[i][0];}
}
printf("%d\n",ans);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 8cb3c3c643a67f985a2b77e28451fe92 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int argc, char const *argv[])
{
int n,v,i,j=0,sum=0;
int temp;
scanf("%d %d",&n,&v);
int count=0,p_count=0;
int temp1,temp2;
int a[3001]={0};
for(i=0;i<n;i=i+1){
scanf("%d %d",&temp1,&temp2);
a[temp1]+=temp2;
}
for(i=1;i<3001;i=i+1){
if(p_count+a[i]<v){
count+=p_count+a[i];
p_count=0;
}else{
count+=v;
p_count=p_count>v?a[i]:p_count+a[i]-v;
}
}
if(p_count<=v){
count+=p_count;
}else{
count+=v;
}
printf("%d\n",count);
return 0;
} | |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 1b62e0fb0b52653ad84bb8ab87e0db96 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | # include <stdio.h>
int main()
{
int n,m,a,b,x[3003]={0},i,sum=0,s;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
x[a]+=b;
}
s=m;
for(i=0;i<3002;i++)
{
if(x[i]<=s){ sum+=x[i]; s=m; continue; }
sum+=s;
if(x[i]-s<=m){sum=sum+x[i]-s; s=m-x[i]+s; continue ;}
sum+=m; s=0;
}
printf("%d",sum);
return 0;
} | |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | f60a7f25da85cbc9b23b6b7fbd0e82cb | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] |
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define sc scanf
#define pr printf
#define dnum 3010
#define Min(a,b) a>b?b:a
#define Max(a,b) a>b?a:b
int n,m,i,j,k,sum,d,t[dnum],tmp1,tmp2,max,min,ans,x,v,a[dnum];
char str[dnum];
int main()
{
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
scanf("%d%d", &n, &v);
for(i = 0; i <n; ++i)
{
scanf("%d%d",&x,&j);
a[x] =a[x] + j;
}
for(i = 1; i <= 3001; ++i)
{
if(i == 1)
{
if(a[i] >= v)
{
sum +=v;
a[i] -= v;
}
else
{
sum += a[i];
a[i] = 0;
}
}
else
{
tmp1 = v;
if(a[i-1] >= tmp1)
{
sum += tmp1;
a[i-1] = 0;
}
else
{
sum += a[i-1];
tmp1 -= a[i-1];
if(a[i] >= tmp1)
{
sum += tmp1;
a[i] -= tmp1;
}
else
{
sum += a[i];
a[i] = 0;
}
}
}
}
printf("%d\n",sum);
return 0;
} | |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | b09f9ccabf98d9ae851054f9104e4e24 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
long left[3001]={0},a[3001],b[3001],s[3001];
int main()
{
long ans=0,n,m,i,max=0;
scanf("%ld%ld",&n,&m);
for(i=1;i<=n;i++)
{
scanf("%ld%ld",&a[i],&b[i]);
if(a[i]>max)max=a[i];
s[a[i]]+=b[i];
}
for(i=1;i<=max+1;i++)
{
if(left[i-1]>=m)
{
ans+=m;
left[i]=s[i];
}
else
{
if(s[i]+left[i-1]>=m)
{
ans+=m;
left[i]=left[i-1]+s[i]-m;
}
else
ans+=s[i]+left[i-1];
}
}
printf("%ld",ans);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 064cf3ce63e647d41b1ac3644a2cf2a2 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
int main()
{
int n,v,i,sum=0,max=0;
scanf("%d%d",&n,&v);
int a[4000],b[4000],s[4000]={0};
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
scanf("%d",&b[i]);
s[a[i]]=s[a[i]]+b[i];
if(a[i]>max)max=a[i];
}
int c,d;
if(s[1]<v)
{
c=0;
sum=sum+s[1];
}
else
{
c=s[1]-v;
sum+=v;
}
//printf("%d %d\n",sum,max);
for(i=2;i<=max+1;i++)
{
if(i==max+1)
s[i]=0;
if(c>v)
{
c=s[i];
sum+=v;
}
else if(c+s[i]<v)
{
sum+=c+s[i];
c=0;
}
else if(c+s[i]>=v)
{
c=c+s[i]-v;
sum+=v;
}
// printf("i=%d sum=%d",i,sum);
}
printf("%d",sum);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | c1dd0fc272d0071ff7b41d3aa13dc0f9 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
#include<stdlib.h>
long long int num_trees,j,i;
int num_fruits[10000000]={0};
int main()
{
int var,max_collect,ans,remaining_fruits,num_days=0;
scanf("%lld%d", &num_trees, &max_collect);
for(i=0;i<(num_trees+5);i++)
{
num_fruits[i]=0;
}
int max=0;
for(i=0;i<num_trees;i++)
{
scanf("%lld%d", &j, &var);
if(j>max)
max = j;
// if(num_fruits[j] ==0)
// num_days++;
num_fruits[j] += var;
}
num_days = max;
if(num_fruits[1]>=max_collect)
{
num_fruits[1] = num_fruits[1] - max_collect;
ans = max_collect;
}
else
{
ans = num_fruits[1];
num_fruits[1] = 0;
}
for(i=2;i<=(num_days+1);i++)
{
remaining_fruits = max_collect;
if(num_fruits[i-1] > 0)
{
if(num_fruits[i-1]>=max_collect)
{
num_fruits[i-1] = num_fruits[i-1] - max_collect;
ans += max_collect;
remaining_fruits = 0;
}
else
{
ans += num_fruits[i-1];
remaining_fruits = max_collect - num_fruits[i-1];
num_fruits[i-1] = 0;
}
}
if(remaining_fruits>0)
{
if((i<=num_days) && (num_fruits[i] > 0))
{
if(num_fruits[i]>=remaining_fruits)
{
num_fruits[i] = num_fruits[i] - remaining_fruits;
ans += remaining_fruits;
}
else
{
ans += num_fruits[i];
num_fruits[i] = 0;
}
}
}
}
printf("%d\n", ans);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 5abf3a3e026895178dd22cfa095db438 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
int min(int x,int y){
if(x>y)
return y;
else
return x;
}
int main(){
int tmp,ans=0,i,j,k,l,n,m,today,last,x,y;
int a[3005]={0};
scanf("%d%d",&n,&k);
for(i=0;i<n;i++){
scanf("%d%d",&x,&y);
a[x] += y;
}
last = 0;
for(i=1;i<=3001;i++){
tmp = k;
if(last >= tmp){
ans += tmp;
last = a[i];
}
else{
ans += last;
tmp -= last;
if(tmp >= a[i]){
ans += a[i];
last = 0;
}
else{
ans += tmp;
last = a[i]-tmp;
}
}
}
printf("%d\n",ans);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 8ed47617b2d1c11ed4e53449fb3045cf | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include <stdio.h>
int tree[3005];
int main()
{
int n,v,max=0,ans=0,i,a,b;
scanf("%d%d",&n,&v);
while(n--)
{
scanf("%d%d",&a,&b);
tree[a]+=b;
if(a>max)
max=a;
}
for(i=1;i<=max+1;i++)
{
if(tree[i]<=v)
{
if(tree[i-1]<=v-tree[i])
{
ans+=tree[i-1]+tree[i];
tree[i]=0;
}
else
{
ans+=v;
int c=v-tree[i-1];
if(c>0)
tree[i]-=c;
}
}
else
{
ans+=v;
int c=v-tree[i-1];
if(c>0)
tree[i]-=c;
}
}
printf("%d\n",ans);
return 0;
} | |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | a1755d624b972a7727ebd76739955352 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
#include<string.h>
int main()
{
long int qian[4000];
long int hou[4000];
int n,v;
long int num;
int i;
int a,b,m;
while(scanf("%d %d",&n,&v)!=EOF)
{
m=0;
memset(qian,0,sizeof(qian));
memset(hou,0,sizeof(hou));
for(i=1;i<=n;i++)
{
scanf("%d %d",&a,&b);
hou[a]=hou[a]+b;
if(m<a)
m=a;
}
num=0;
for(i=1;i<=m+1;i++)
{
if((hou[i]+qian[i])<=v)
{
num=num+hou[i]+qian[i];
}
else
{
if(qian[i]<v)
{
num=num+v;
qian[i+1]=qian[i+1]+hou[i]+qian[i]-v;
}
else
{
num+=v;
qian[i+1]=qian[i+1]+hou[i];
}
}
}
printf("%ld\n",num);
}
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 331bafb575ba8d6822986ca24641dc9a | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
int main()
{
int i,j,tree,v,now;
scanf("%d %d",&tree,&v);
int day,f,a[3002]={0};
for(i=0;i<tree;i++)
{
scanf("%d %d",&day,&f);
a[day]+=f;
}
int prev=0;
__int64 tot=0;
for(j=1;j<=3001;j++)
{
now=a[j];
if(now+prev<=v)
{
tot=tot+now+prev;
prev=0;
continue;
}
else
{
if(prev<=v)
{
tot=tot+v;
//tot=tot+now-v+prev;
prev=now-v+prev;
continue;
}
if(prev>v)
{
tot=tot+v;
prev=now;
continue;
}
}
}
printf("%I64d",tot);// only tot is the integer dat will get beyond d range of integer value...
return 0;
} | |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 6b29994eea0a62132026aa20f8ba3a09 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | // c99.c by Bill Weinman <http://bw.org/>
#include <stdio.h>
int min(int a,int b)
{
if(a>b)return b;
else return a;
}
int main()
{
int i,n,v,x,n1;
scanf("%d%d",&n,&v);
int d[3005];
for(i=0;i<3005;i++)
{
d[i]=0;
}
for(i=0;i<n;i++)
{
scanf("%d%d",&x,&n1);
d[x]=d[x]+n1;
}
int sum,v1,z;
sum=0;
for(i=1;i<=3001;i++)
{
v1=v;
if(d[i-1]>0)
{
z=min(d[i-1],v1);
d[i-1]=d[i-1]-z;
v1=v1-z;
sum=sum+z;
}
if(d[i]>0 && v1>0)
{
z=min(d[i],v1);
d[i]=d[i]-z;
sum=sum+z;
}
}
printf("%d\n",sum);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 4b6af1b10496566991d39f8d07bf4fe3 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
#include<stdlib.h>
#define MAX 3005
int main() {
int n,v;
long int a[MAX],b[MAX],tv;
int day,num;
long int j,i,temp;
long long int col,cur;
long int max,rem;
scanf("%d %d",&n,&v);
for(i=0;i<MAX;i++) {
b[i]=a[i]=0;
}
max=0;
for(i=0;i<n;i++) {
scanf("%d %d",&day,&num);
b[i]=day;
a[i]=num;
}
rem=0;
col=0;
for(i=1;i<=3001;i++) {
cur=0;
for(j=0;j<n;j++) {
if(b[j]==i)
cur += a[j];
}
if((rem+cur) <= v) {
col =col + cur + rem;
rem=0;
}
else {
col = col + v;
tv=v-rem;
if(tv<0)
tv=0;
rem=cur-tv;
}
}
printf("%I64d\n",col);
return 0;
}
| |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | c1cf9fc19c8469579cb8181942ae4a30 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
#include<string.h>
int tree[3010],f[3010][2];
int main()
{
int n,v,i,j,k,res,a,b,temp;
while(scanf("%d%d",&n,&v)!=EOF)
{
res=0;
memset(tree,0,sizeof(tree));
for(i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
if(tree[a]==0)
{
tree[a]=b;
}
else
tree[a]+=b;
}
for(i=0;i<3005;i++)
{
if(i==0)
{
if(tree[i]>v)
{
tree[i]=tree[i]-v;
res+=v;
}
else
{
res+=tree[i];
tree[i]=0;
}
}
else
{
temp=v;
if(tree[i-1]>temp)
{
res+=temp;
temp=0;
}
else
{
res+=tree[i-1];
temp=temp-tree[i-1];
if(tree[i]>temp)
{
res+=temp;
tree[i]=tree[i]-temp;
}
else
{
res+=tree[i];
tree[i]=0;
}
}
}
}
printf("%d\n",res);
}
return 0;
} | |
Valera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well? | Print a single integer — the maximum number of fruit that Valera can collect. | C | 848ead2b878f9fd8547e1d442e2f85ff | 75ee0f8b3b3e587957b870d20f1db69a | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy"
] | 1402241400 | ["2 3\n1 5\n2 3", "5 10\n3 20\n2 20\n1 20\n4 20\n5 20"] | NoteIn the first sample, in order to obtain the optimal answer, you should act as follows. On the first day collect 3 fruits from the 1-st tree. On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. On the third day collect the remaining fruits from the 2-nd tree. In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither. | PASSED | 1,400 | standard input | 1 second | The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree. | ["8", "60"] | #include<stdio.h>
int main(void)
{
int no_trees,max_fruits,i,day,no_fruits[4000],remain,collect,max_day,array[3];
scanf("%d", &no_trees);
scanf("%d", &max_fruits);
max_day=0;
for(i=1;i<=4000;i++)
{
no_fruits[i]=0;
}
for(i=1;i<=no_trees;i++)
{
scanf("%d", &day);
if(day>max_day)
{
max_day=day;
}
int x;
scanf("%d", &x);
no_fruits[day]+=x;
}
remain=0;
collect=0;
array[2]=0;
array[1]=0;
for(i=1;i<=max_day+1;i++)
{
array[2]=array[1];
array[1]=no_fruits[i];
// printf("fruits on day %d in 1=%d fruits in 2=%d\n",i,array[1],array[2]);
if(array[2]>=max_fruits)
{
collect=collect+max_fruits;
}
else
{
collect=collect+array[2];
if(array[1]>=max_fruits-array[2])
{
array[1]=array[1]-(max_fruits-array[2]);
collect=collect+(max_fruits-array[2]);
}
else
{
collect=collect+array[1];
array[1]=0;
}
// array[2]=0;
}
array[2]=0;
//printf("eeeeeefruits in 1=%d fruits in 2=%d\n",array[1],array[2]);
}
printf("%d\n", collect);
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | f2ea0b357e0cae2b1abe25ee3586db06 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n,i,a,b,c,y=2;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d",&a,&b);
if(a!=b)
{
printf("rated\n"),y=1;
break;
}
else
{
if(c==0){c=a;}
else if(c>=a){c=a;if(y!=0){y=2;}}
else c=a,y=0;
}
}
if(y==2){printf("maybe\n");}
else if(y==0){printf("unrated\n");}
return 0;
} | |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 50fea4402c7bde1eec7aa90f7d9f8e8d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
int n, i, a, b, a1 = 1e9, k;
int main()
{
scanf("%d", &n);
for(i = 0; i < n; i++){
scanf("%d%d", &a, &b);
if (a != b){
k = 1;
break;
}
if(a > a1)
k = 2;
a1 = a;
}
switch(k){
case 1:
printf("rated\n");
break;
case 2:
printf("unrated\n");
break;
default:
printf("maybe\n");
}
return 0;
} | |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 3a7e0c95e438d078d7eddb018ef0a565 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main()
{
int n,i,j,k=0,c=0;
scanf("%d",&n);
int a[n][2];
for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
if(a[i][0]!=a[i][1])
{
k++;
}
}
if(k>0)
{
printf("rated\n");
}
else
{
for(i=0;i<(n-1);i++)
{
if(a[i][0]<a[i+1][0])
{
c++;
break;
}
}
if(c>0)
printf("unrated\n");
else
printf("maybe\n");
}
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | d75ca9cab8ff937e122686095654a663 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
#include <stdlib.h>
void main(int argc, const char * argv[]) {
int n,i;
scanf("%d",&n);
int before[n],after[n];
for ( i=0;i<n;i++)
{
scanf("%d%d",&before[i],&after[i]);
if (before[i]!=after[i])
{
printf("rated\n");
return;
}}
for(int i=1; i<n; i++) {
if(before[i] > before[i-1]) {
printf("unrated\n");
return;
}
}
printf("maybe\n");
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | afab21d0c0d9bc5359bd95059c67bef8 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
typedef enum{
false,
true
} bool;
int main(){
int n; scanf("%d",&n);
int matrix[n][2];
int i, j;
bool maybe=1;
bool sure=0;
for(i=0; i<n; i++){
scanf("%d %d",&matrix[i][0], &matrix[i][1]);
if(matrix[i][0]!=matrix[i][1])
sure=1;
if(i>0)
if(matrix[i][0]>matrix[i-1][0] || matrix[i][1]>matrix[i-1][1])
maybe=0;
}
if(sure)
printf("rated");
else
if(maybe)
printf("maybe");
else
printf("unrated");
return 0;
} | |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 19e007f5bf1118081e8cf21c999cf5ac | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
int main(){
int n,i,f=0;
scanf("%d",&n);
int a[n][2];
for (i=0;i<n;i++){
scanf("%d %d",&a[i][0],&a[i][1]);
if (a[i][0]!=a[i][1])
f=1;
}
if (f==1){
printf("rated");
return 0;
}
f=0;
for (i=0;i<n-1;i++){
if (a[i+1][0]>a[i][0]){
f=1;
break;
}
}
if (f==1){
printf("unrated");
}
else if (f==0){
printf("maybe");
}
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | fbba3e647d5b7064b7adab9e36676433 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int m,n,a[1010],b[1010];
int i,j;
int flag=0;
while(~scanf("%d",&n))
{
flag=0;
for(i=0;i<n;i++)
{
scanf("%d%d",&a[i],&b[i]);
if(a[i]!=b[i])
flag=1;
}
for(i=1;i<n;i++)
{
if(a[i]>a[i-1]&&flag==0)
flag=2;
}
if(flag==0)
printf("maybe\n");
else if(flag==1)
printf("rated\n");
else
printf("unrated\n");
}
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 1602778a941e289ce2b4cd014d14978b | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main()
{
int i,count=0,j,n;
int a[10000],b[10000];
while(scanf("%d",&n)==1)
{
count=0;
for(i=0;i<n;i++)
{
scanf("%d %d",&a[i],&b[i]);
if(a[i]!=b[i])
count++;
}
if(count>0)
printf("rated\n");
else
{
count=0;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]<a[j])
{
count++;
break;
}
}
if(count==1)
break;
}
if(count==1)
printf("unrated\n");
else
printf("maybe\n");
}
}
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | bd427b61d4da5453d542a87fb7eb49ad | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
int main()
{
int i, n, a, b, c, d, u;
scanf("%d", &n);
scanf("%d %d", &a, &b);
if (a != b) {
printf("rated\n");
return 0;
}
u = 0;
for (i = 0; i < n; i++) {
scanf("%d %d", &c, &d);
if (c != d) {
printf("rated\n");
return 0;
} else if (a < c) {
u = 1;
}
a = c;
b = d;
}
if (u == 1) {
printf("unrated\n");
} else {
printf("maybe\n");
}
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 320042f43ff20fc7cfe7f3168b8b310d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
long long beforearr[1000001];
long long afterarr[1000001];
char str[1000001];
int func(const void *a, const void *b)
{
return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
return (a>b)?a:b;
}
long long min(long long a, long long b)
{
return (a>b)?b:a;
}
int main()
{
long long int n, i, j, k, count=0, ans=0;
scanf("%lld", &n);
// scanf("%s", str);
for(i=0;i<n;i++)
scanf("%lld %lld", &beforearr[i], &afterarr[i]);
long long flag=0;
for(i=0;i<n;i++)
if(beforearr[i]!=afterarr[i])
{flag=1;break;}
if(flag)
printf("rated\n");
else
{
long long min=10000000000000000;
for(i=0;i<n;i++)
if(beforearr[i]<beforearr[i+1])
flag=1;
if(flag)
printf("unrated\n");
else
printf("maybe\n");
}
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | cb37d2080c6cf520fe8358ee56bfdc64 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
int main()
{
int n,a[1001],b[1001],i;
scanf("%d",&n);
for (i=0;i<n;i++){
scanf("%d%d",&a[i],&b[i]);
}
for (i=0;i<n;i++){
if (a[i]!=b[i])
break;
}
if (i<n){
printf("rated\n");
return 0;
}
for (i=0;i<n;i++){
if (a[i]>a[i-1] && i!=0)
break;
}
if (i==n)
printf("maybe\n");
else
printf("unrated\n");
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | a4dbafa043c10fb66f52f639d4c2a8b6 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main()
{
int n,i,flag=0,j;
scanf("%d",&n);
long long int a[n];
int b[n];
for(i=0;i<n;i++){
scanf("%lld%d",&a[i],&b[i]);
}
for(i=0;i<n;i++){
if(a[i]!=b[i]){
flag=1;
break;
}
else{
flag=2;
}
}
if(flag==2){
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if((a[i]<a[j])||(b[i]<b[j])){
flag=3;
break;
}
}
}
}
if(flag==1){
printf("rated");
}
else if(flag==3){
printf("unrated");
}
else{
printf("maybe");
}
return 0;
} | |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | cb1fc5236e6ca425760a7d28a18e6eb1 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int n;
int cmp(const void * a, const void * b)
{
return (*(int *)b - *(int *)a);
}
bool are(int a[], int b[], int c)
{
int i;
for(i = 0; i < n; i++)
{
if(a[i] != b[i])
{
return false;
}
}
return true;
}
int main()
{
int i,a[10000],b[10000],c[10000];
scanf("%d",&n);
for(i = 0; i < n; i++)
{
scanf("%d %d",&a[i],&b[i]);
c[i] = a[i];
}
qsort(c,n,sizeof(int),cmp);
if(!are(a,b,n))
{
printf("rated\n");
}
else
{
if(are(c,a,n))
{
printf("maybe\n");
}
else
{
printf("unrated\n");
}
}
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | f7ef44f71d7060134fc8ab1c8517ad45 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main(){
int i,n,ok;
scanf("%d",&n);
int c[n],t[n];
for(i=0;i<n;i++){
scanf("%d %d",&c[i],&t[i]);
}
for(i=0;i<n;i++){
if(c[i]!=t[i]){
printf("rated");
return 0;
}
}
for(i=0;i<n-1;i++){
if(c[i]<c[i+1]){
printf("unrated");
return 0;
}
}
printf("maybe");
} | |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | c77216f1ce4fb91c3d2b5127a3109c71 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main(){
int n ,b ,index=0 ,i ,c=0;
scanf("%d" ,&n);
b=2*n;
int rate[b];
for(i=0;i<b;i++){
scanf("%d" ,&rate[i]);
if(i%2==0 && i!=0 && index==0) {
if(rate[i]>rate[i-2]) index=1;
}
else if(i%2!=0){
if(rate[i]==rate[i-1]) c++;
}
}
if(c<n) printf("rated\n");
else {
if(index==1) printf("unrated\n");
else printf("maybe\n");
}
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 762e4ac2f62899d2ba46e52e8f8c5caa | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main()
{
int t,x,y,x1=0,count=0,i,sum=0,d;
scanf("%d",&t);
for(i=1;i<=t;i++){
scanf("%d%d",&x,&y);
d=x-y;if(d<0) d=-d;
sum=sum+d;
if(x1>=x) count++;
x1=x;
}
if(sum!=0){
printf("rated") ;
}
else{
if(count==t-1)
printf("maybe") ;
else
printf("unrated");
}
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 7eb1da84a6faecb3f2b46d34d89c4a09 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main(){
int n,chk,i,x,y,j,Min;
scanf("%d",&n);
int b[n];
for(i=0,chk=1;i<n;i++){
scanf("%d%d",&x,&y);
if(x==y)b[i]=y;
else {chk=0;for(i=i;i<n;i++)scanf("%d",&x);}
}
if(chk==0)printf("rated");
else {
for(i=1,chk=1,Min=b[0];i<n;i++){
if(Min<b[i]){chk=0;break;}
else Min = b[i];
}
if(chk==1)printf("maybe");
else printf("unrated");
}
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 15bd4527e7abf6b07e4923f2581b8bca | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main(){
int n,a,b,last=10000,rated=0,unrated=0;
scanf("%d",&n);
while(n--){
scanf("%d%d",&a,&b);
if(a!=b)rated=1;
if(b > last)unrated = 1;
last = b;
}
if(rated)printf("rated\n");
else if(unrated)printf("unrated\n");
else printf("maybe\n");
return 0;
} | |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 1b51cd3b9ba0a98373dc0ca73a6e0622 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
int main()
{
int n,i;
int a[1000],b[1000];
scanf("%d",&n);
for(i = 0; i < n; i++)
{
scanf("%d%d",&a[i],&b[i]);
if (a[i] != b[i])
{
printf("rated\n");
return 0;
}
}
for(i = 1; i < n; i++)
{
if (a[i-1] < a[i])
{
printf("unrated\n");
return 0;
}
}
printf("maybe\n");
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 8f063dd6aa35b8aa855cdc68a9761aab | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main()
{
int n, a[1000], b[1000], p, c,i;
scanf("%d", &n);
for(i = 0; i < n; i++){
scanf("%d%d", &a[i], &b[i]);
}
for(i = 0; i < n; i++){
if(a[i] == b[i]){
p = 0;
}
else{
p = 1;
break;
}
}
if(p == 1){
printf("rated");
}
else{
for(i = 0; i < n-1; i++){
if(a[i] >= a[i+1]){
c = 1;
}
else{
c = 0;
printf("unrated");
break;
}
}
if(c == 1){
printf("maybe");
}
}
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 2cbaf7e6a2ecb58a62b46a4ab079b8b5 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] |
#include<stdio.h>
int main()
{
int i,j,k,n,a[4126],b[4126],sum=0,sum2=0;
double c=1,x;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d",&a[i],&b[i]);
}
for(i=0;i<n;i++){
x= a[i]/b[i];
if(a[i]>b[i] || a[i] < b[i]){
sum=n;
break;
}
}
if (sum==n){
printf("rated");
}
else if(sum!=n){
for(i=0;i<n;i++){
if(a[i]>=a[i+1]){
sum2=sum2+1;
}
else{
break;
}
}
if(sum2==n){
printf("maybe");
}
else{
printf("unrated");
}
}
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 3459424ce8ef726a02fc50ec46f9d230 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
int main(int argc, char const *argv[])
{
int i,n;
int a,b;
int equal,increase;
int prea;
while(~scanf("%d",&n))
{
a = 0;
prea = 4200;
equal = 0;
increase = 1;
for(i = 1; i <= n; i++)
{
scanf("%d %d",&a,&b);
if(a != b)
equal = 1;
if(a > prea)
increase = 0;
prea = a;
}
if(equal)
printf("rated\n");
else if(!increase)
printf("unrated\n");
else printf("maybe\n");
printf("\n");
}
return 0;
} | |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 6f665f48dd53122216fce1d018dae197 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | //http://codeforces.com/contest/807/problem/0
#include<stdio.h>
int main()
{
int i,n,check; scanf("%d",&n);
int a[n],b[n];
check=0;
for(i=0;i<n;i++)
{
scanf("%d %d",&a[i],&b[i]);
if(a[i]!=b[i])
{
check=1;
break;
}
}
if(check==1)
printf("rated");
else
{
for(i=0;i<n-1;i++)
{
if(a[i+1]>a[i])
{
check=-1;
break;}
}
}
if(check==-1)
printf("unrated");
else if(check==0)
printf("maybe");
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 2a6957c75166345ddf26361fa0620630 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include<stdio.h>
int main(void)
{
int i,n,trap=0,trap2=0,a[1005],b[1005];
scanf("%d",&n);
for(i=0;i<n;i++) {
scanf("%d %d",&a[i],&b[i]);
if(a[i]!=b[i]) {
trap=1;
}
if(!trap) {
if((i>0) && (a[i-1]<a[i])) {
trap2=1;
}
}
}
if(trap) {
printf("rated");
}
else {
if(trap2) {
printf("unrated");
return 0;
}
printf("maybe");
}
return 0;
}
| |
Is it rated?Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.It's known that if at least one participant's rating has changed, then the round was rated for sure.It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.In this problem, you should not make any other assumptions about the rating system.Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not. | If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe". | C | 88686e870bd3bfbf45a9b6b19e5ec68a | 6ba0962f4ce94b7cb382aa2be80c8d44 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"sortings"
] | 1494171900 | ["6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699"] | NoteIn the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not. | PASSED | 900 | standard input | 2 seconds | The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings. | ["rated", "unrated", "maybe"] | #include <stdio.h>
int main(){
int n,i,num11,num12,num21,num22,flag=0;
scanf("%d",&n);
for(i=0;i<n;i++){
if(i != 0){
num11=num21;
num12=num22;
}
scanf("%d %d",&num21,&num22);
if (i!=0){
if(num21 > num11){
flag=1;
}
}
if(num21 != num22) {
printf("rated\n");
return 0;
}
}
if(flag==1) {
printf("unrated\n");
return 0;
}
printf("maybe\n");
return 0;
} | |
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single charger that can plug to any single device. The charger will add p units of power per second to a device. This charging is continuous. That is, if you plug in a device for λ seconds, it will gain λ·p units of power. You can switch which device is charging at any arbitrary unit of time (including real numbers), and the time it takes to switch is negligible.You are wondering, what is the maximum amount of time you can use the devices until one of them hits 0 units of power.If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. | If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker program will consider your answer correct if . | C | 1c2fc9449989d14d9eb02a390f36b7a6 | 6c32a042118cda9ea57ff05aff93c1e3 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"binary search",
"math"
] | 1492356900 | ["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"] | NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to charge the second device for a 1 / 10 of a second. | PASSED | 1,800 | standard input | 2 seconds | The first line contains two integers, n and p (1 ≤ n ≤ 100 000, 1 ≤ p ≤ 109) — the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≤ ai, bi ≤ 100 000) — the power of the device and the amount of power stored in the device in the beginning. | ["2.0000000000", "-1", "0.5000000000"] | #include <stdio.h>
#include <float.h>
#include <stdbool.h>
#include <assert.h>
#define MAXN 100000
#define MAX(x, y) ((x) > (y)? (x): (y))
int main()
{
int n, p, a[MAXN], b[MAXN];
long long int total_consumption = 0;
scanf("%d%d", &n, &p);
for (int i = 0; i < n; i++) {
scanf("%d%d", &a[i], &b[i]);
total_consumption += a[i];
}
if (p >= total_consumption) {
puts("-1");
return 0;
}
long double lb = 0, ub = 10e14;
int iteration = 0;
while (iteration < 220) {
const long double mid = lb/2 + ub/2;
long double req_charge_t = 0;
bool OK = true;
for (int i = 0; i < n; i++) {
if ((long double)b[i]/a[i] >= mid) {
continue;
} else {
req_charge_t += (mid*a[i] - b[i])/p;
if (req_charge_t > mid) {
OK = false;
break;
}
}
}
if (OK) lb = mid;
else ub = mid;
iteration++;
}
printf("%.10f\n", (double)(lb/2 + ub/2));
return 0;
}
| |
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single charger that can plug to any single device. The charger will add p units of power per second to a device. This charging is continuous. That is, if you plug in a device for λ seconds, it will gain λ·p units of power. You can switch which device is charging at any arbitrary unit of time (including real numbers), and the time it takes to switch is negligible.You are wondering, what is the maximum amount of time you can use the devices until one of them hits 0 units of power.If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. | If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker program will consider your answer correct if . | C | 1c2fc9449989d14d9eb02a390f36b7a6 | c81117258b12445d5a46a0ccd78e6ed4 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"binary search",
"math"
] | 1492356900 | ["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"] | NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to charge the second device for a 1 / 10 of a second. | PASSED | 1,800 | standard input | 2 seconds | The first line contains two integers, n and p (1 ≤ n ≤ 100 000, 1 ≤ p ≤ 109) — the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≤ ai, bi ≤ 100 000) — the power of the device and the amount of power stored in the device in the beginning. | ["2.0000000000", "-1", "0.5000000000"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
long long a[100005];
long long b[100005];
long long n, p;
long double max(long double a, long double b) {
return a > b ? a : b;
}
int main(void) {
while(scanf("%I64d%I64d", &n, &p) != -1) {
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));;
long long suma = 0;
for(int i = 0; i < n; i += 1) {
scanf("%I64d%I64d", &a[i], &b[i]);
suma += a[i];
}
if(p >= suma) {
printf("-1\n");
continue;
}
long double l = 0.0;
long double r = 1e18;
while(r - l > 1e-6) {
long double m = (l + r) / 2;
long double need = 0;
for(int i = 0; i < n; i += 1) {
need += max(0.0, (m - (1.0 * b[i] / a[i])) * a[i]);
}
if(m * p > need) {
l = m;
} else {
r = m;
}
}
printf("%Lf\n", l);
}
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | f5787d963f56d0063f71909f0ca41b79 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
int main()
{
int i,n,ara[1000];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&ara[i]);
for(i=0;i<n;i++)
{
if(ara[i]&1)
printf("%d ",ara[i]);
else
printf("%d ",ara[i]-1);
}
return 0;
} | |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | 1b9e015973145f1d6b9b47a09a40fb50 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
int main()
{
int a,b,i,j;
long long int c,d;
scanf("%d",&a);
for(i=0;i<a;i++)
{
scanf("%lld",&c);
if(c%2==0)
{
d=c-1;
printf("%lld ",d);
}
else
{
printf("%lld ",c);
}
}
return 0;
} | |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | 5a6abc25d61cf9700d1c622330b3fbb7 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
int main()
{
int a,b,i,j;
long long int c,d;
scanf("%d",&a);
for(i=0;i<a;i++)
{
scanf("%lld",&c);
if(c%2==0)
{
d=c-1;
printf("%lld ",d);
}
else
{
printf("%lld ",c);
}
}
return 0;
} | |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | 32a142275c9234a651d2acd9192fb28c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
int main(){
int n;
int a[1000];
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int i=0;i<n;i++)
{
if(a[i]%2==0)
printf("%d ",a[i]-1);
else
printf("%d ",a[i]);
}
return 0 ;
} | |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | e9e21b946e1c42959cb235654bcdc537 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
int main ()
{
int n;
scanf("%d",&n);
int a[n];
int i;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i]%2==0)
{
printf("%d ",a[i]-1);
}
else
{
printf("%d ",a[i]);
}
}
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | 5dbfa71b9c3b0847e00abead4d28dea3 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int N;
scanf("%d",&N);
int arr[N];
for(int i=0; i<N; i++){
scanf("%d",&arr[i]);
}
for(int i=0; i<N; i++){
if(arr[i]%2==0)arr[i]=arr[i]-1;
}
for(int i=0; i<N; i++){
printf("%d ",arr[i]);
}
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | ebbffd57a5ad43b474c243eaa8fe188e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include <stdio.h>
int main(){
int n;
//freopen("input.txt","r",stdin);
scanf("%d",&n);
int a[n];
int i;
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]%2==0) printf("%d ",a[i]-1);
else printf("%d ",a[i]);
}
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | b461196b8acd5e9684996a766257b7aa | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
main()
{
int i,n;
scanf("%d",&n);
int a[n];
for(i=0;i<=(n-1);i++)
{
scanf("%d",&a[i]);
if(a[i]%2==0)
a[i]=a[i]-1;
}
for(i=0;i<=(n-1);i++)
printf("%d ",a[i]);
printf("\n");
} | |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | c448f920d2f12a6edadc4f117c4ef030 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
int main()
{
int n,i;
int a[1000];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i]%2==0)
{
a[i]=a[i]-1;
}
}
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
return 0;
} | |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | e74392f1e22fdd09ecd3c5efd1244918 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int a[1000];
int i,n;
scanf("%d",&n);
for(i=0; i<n; i++)
scanf("%d",&a[i]);
for(i=0; i<n-1; i++){
if(a[i]%2!=0)
a[i]++;
}
for(i=0; i<n; i++){
if(a[i]%2==0)
a[i]--;
}
for(i=0; i<n; i++)
printf("%d ",a[i]);
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | 7d7ef9172523ea58a317c4b60b312146 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
int main()
{
int n,i;
long a[1000];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]==a[i]/2*2)a[i]-=1;
}
for(i=0;i<n;i++)
printf("%d ",a[i]);
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | 8bcbafb4bc7a048fc8aae0343eac9bb5 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include <stdio.h>
int main()
{
int a, i, n;
scanf ("%d", &n);
for (i = 0; i < n; i++) {
scanf ("%d", &a);
printf ("%d ", a - !(a & 1));
}
printf ("\n");
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | cae0cfd06d1612b428edc3eb3cc4bd1f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i, n;
scanf ("%d", &n);
int *a = (int*) malloc (sizeof(int) * n);
for (i = 0; i < n; i++) {
scanf ("%d", a + i);
if (a[i] % 2 == 0)
a[i]--;
}
for (i = 0; i < n - 1; i++)
printf ("%d ", a[i]);
printf ("%d\n", a[n - 1]);
free (a);
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | e15ff13c1dbc064b9dc4e67dfe652255 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include <stdio.h>
int main()
{
int n,i;
scanf("%d",&n);
long int a[n];
for(i=0;i<n;i++)
{
scanf("%ld",&a[i]);
if(a[i]%2==0)
a[i]=a[i]-1;
}
for(i=0;i<n;i++)
printf("%ld ",a[i]);
} | |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | b09af2f3687a986ec89c6410f7358677 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
int main()
{
int n,i;
scanf("%d",&n);
long int arr[n];
for(i=0;i<n;i++)
{
scanf("%ld",&arr[i]);
if(arr[i]%2==0)
arr[i]= arr[i]-1;
}
for(i=0;i<n;i++)
printf(" %ld",arr[i]);
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | cd2e473d5da5631b3a59930aad208feb | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
int main()
{
int n;
int a[1005] = {0};
scanf("%d",&n);
for(int i = 0 ; i < n; i ++) scanf("%d",&a[i]);
for(int i = 0 ; i < n-1 ; i ++)
{
if(a[i]&1) printf("%d ",a[i]);
else printf("%d ",a[i]-1);
}
if(a[n-1]&1) printf("%d\n",a[n-1]);
else printf("%d\n",a[n-1]-1);
return 0;
}
| |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | da0fa10aa1c9487afbbd7c30c315de7d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
#include<math.h>
int main()
{
int n;
scanf("%d",&n);
double x[n];
int y;
for(y=0;y<n;y++)
{
scanf("%lf",&x[y]);
}
int z,max;
for(y=0;y<n;y++)
{
if(fmod(x[y],2)==0)
{
x[y]--;
}
printf("%.0lf ",x[y]);
}
} | |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | 6c9725a46e74ff6eda3bab0d62339066 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] | #include<stdio.h>
#include<math.h>
int main()
{
int n;
scanf("%d",&n);
double x[n];
int y;
for(y=0;y<n;y++)
{
scanf("%lf",&x[y]);
}
int z,max;
for(y=0;y<n;y++)
{
if(fmod(x[y],2)==0)
{
x[y]--;
}
printf("%.0lf ",x[y]);
}
} | |
Mishka got an integer array $$$a$$$ of length $$$n$$$ as a birthday present (what a surprise!).Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: Replace each occurrence of $$$1$$$ in the array $$$a$$$ with $$$2$$$; Replace each occurrence of $$$2$$$ in the array $$$a$$$ with $$$1$$$; Replace each occurrence of $$$3$$$ in the array $$$a$$$ with $$$4$$$; Replace each occurrence of $$$4$$$ in the array $$$a$$$ with $$$3$$$; Replace each occurrence of $$$5$$$ in the array $$$a$$$ with $$$6$$$; Replace each occurrence of $$$6$$$ in the array $$$a$$$ with $$$5$$$; $$$\dots$$$ Replace each occurrence of $$$10^9 - 1$$$ in the array $$$a$$$ with $$$10^9$$$; Replace each occurrence of $$$10^9$$$ in the array $$$a$$$ with $$$10^9 - 1$$$. Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers ($$$2i - 1, 2i$$$) for each $$$i \in\{1, 2, \ldots, 5 \cdot 10^8\}$$$ as described above.For example, for the array $$$a = [1, 2, 4, 5, 10]$$$, the following sequence of arrays represents the algorithm: $$$[1, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$1$$$ with $$$2$$$) $$$\rightarrow$$$ $$$[2, 2, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$2$$$ with $$$1$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$3$$$ with $$$4$$$) $$$\rightarrow$$$ $$$[1, 1, 4, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$4$$$ with $$$3$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$5$$$ with $$$6$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 6, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$6$$$ with $$$5$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ $$$\dots$$$ $$$\rightarrow$$$ $$$[1, 1, 3, 5, 10]$$$ $$$\rightarrow$$$ (replace all occurrences of $$$10$$$ with $$$9$$$) $$$\rightarrow$$$ $$$[1, 1, 3, 5, 9]$$$. The later steps of the algorithm do not change the array.Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it. | Print $$$n$$$ integers — $$$b_1, b_2, \dots, b_n$$$, where $$$b_i$$$ is the final value of the $$$i$$$-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array $$$a$$$. Note that you cannot change the order of elements in the array. | C | d00696cb27c679dda6e2e29314a8432b | a78f27baad96a8f00da43f865520cd9f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1531751700 | ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000"] | NoteThe first example is described in the problem statement. | PASSED | 800 | standard input | 1 second | The first line of the input contains one integer number $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of elements in Mishka's birthday present (surprisingly, an array). The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array. | ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 999999999"] |
#include<stdio.h>
int main()
{
int n,a[1000],b[1000],t1=0,t2=0,i,j,t=0;
scanf("%d",&n);
for (i=0;i<n;i++) {
scanf("%d",&a[i]);
b[i]=a[i];
}
for(i=0;i<n-1;i++)
{
for (j=0;j<n-i-1;j++)
{
if(b[j]>b[j+1])
{
t=b[j];
b[j]=b[j+1];
b[j+1]=t;
}
}
}
for (i=0;i<n;i++)
{
for (j=0;j<n;j++)
if (a[j]==b[i])
{
if(b[i]%2==0)
a[j]-=1;
else a[j]+=1;
}
if(b[i+1]!=b[i]+1)
{
for (j=0;j<n;j++)
if (a[j]==b[i]+1)
{
if((b[i]+1)%2==0)
a[j]-=1;
else a[j]+=1;
}
}
}
for (i=0;i<n;i++) printf("%d ",a[i]);
return 0;
} |
Subsets and Splits