prob_desc_description stringlengths 63 3.8k | prob_desc_output_spec stringlengths 17 1.47k β | lang_cluster stringclasses 2 values | src_uid stringlengths 32 32 | code_uid stringlengths 32 32 | lang stringclasses 7 values | prob_desc_output_to stringclasses 3 values | prob_desc_memory_limit stringclasses 19 values | file_name stringclasses 111 values | tags listlengths 0 11 | prob_desc_created_at stringlengths 10 10 | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_notes stringlengths 4 3k β | exec_outcome stringclasses 1 value | difficulty int64 -1 3.5k β | prob_desc_input_from stringclasses 3 values | prob_desc_time_limit stringclasses 27 values | prob_desc_input_spec stringlengths 28 2.42k β | prob_desc_sample_outputs stringlengths 2 796 | source_code stringlengths 42 65.5k | hidden_unit_tests stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
We have a secret array. You don't know this array and you have to restore it. However, you know some facts about this array: The array consists of $$$n$$$ distinct positive (greater than $$$0$$$) integers. The array contains two elements $$$x$$$ and $$$y$$$ (these elements are known for you) such that $$$x < y$$$. If you sort the array in increasing order (such that $$$a_1 < a_2 < \ldots < a_n$$$), differences between all adjacent (consecutive) elements are equal (i.e. $$$a_2 - a_1 = a_3 - a_2 = \ldots = a_n - a_{n-1})$$$. It can be proven that such an array always exists under the constraints given below.Among all possible arrays that satisfy the given conditions, we ask you to restore one which has the minimum possible maximum element. In other words, you have to minimize $$$\max(a_1, a_2, \dots, a_n)$$$.You have to answer $$$t$$$ independent test cases. | For each test case, print the answer: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the $$$i$$$-th element of the required array. If there are several answers, you can print any (it also means that the order of elements doesn't matter). It can be proven that such an array always exists under the given constraints. | C | ca9d97e731e86cf8223520f39ef5d945 | e71fb3dc9c2d78dc0467bfe41eefd0f6 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"number theory",
"brute force",
"math"
] | 1599230100 | ["5\n2 1 49\n5 20 50\n6 20 50\n5 3 8\n9 13 22"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) β the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$n$$$, $$$x$$$ and $$$y$$$ ($$$2 \le n \le 50$$$; $$$1 \le x < y \le 50$$$) β the length of the array and two elements that are present in the array, respectively. | ["1 49 \n20 40 30 50 10\n26 32 20 38 44 50 \n8 23 18 13 3 \n1 10 13 4 19 22 25 16 7"] | ///I must try more than once
#include<stdio.h>
#include<math.h>
void test()
{
int n,x,y;
scanf("%d%d%d",&n,&x,&y);
int sub=y-x,b=sqrt(sub);
int i,aa,bb,max,ans,qq,mul;
ans=sub*(n-2)+y,qq=sub;
///printf("%d\n",ans);
for(i=1;i<=b;i++){
if(sub%i==0){
mul=sub/i;
///printf("mul =%d i = %d\n",mul,i);
aa=i+1; //for mul i=1,aa=2
bb=mul+1; //for i mul=sub,bb=mul+1
///printf("aa =%d bb = %d\n",aa,bb);
if(aa<=n){
if(x%mul==0) aa+=x/mul-1;
else aa+=x/mul;
if(aa<n) max=(n-aa)*mul+y;
else max=y;
if(max<ans){
ans=max;
qq=mul;
}
///printf("%d %d\n",ans,aa);
}
if(bb<=n){
if(x%i==0) bb+=x/i-1;
else bb+=x/i;
if(bb<n) max=(n-bb)*i+y;
else max=y;
if(max<ans){
ans=max;
qq=i;
}
///printf("%d %d\n",ans,bb);
}
}
}
max=x;
///printf("ans = %d\n",ans);
printf("%d ",x);
for(i=2;i<=n;i++){
if(max+qq>ans){
x=x-qq;
printf("%d ",x);
}
else {
max=max+qq;
printf("%d ",max);
}
}
printf("\n");
}
int main()
{
int t;
scanf("%d",&t);
while(t--) test();
}
| |
Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher that he isn't going to become a writer? In fact, he is going to become a programmer. So, he would take great pleasure in writing a program, but none β in writing a composition.As Vasya was fishing for a sentence in the dark pond of his imagination, he suddenly wondered: what is the least number of times he should push a key to shift the cursor from one position to another one?Let's describe his question more formally: to type a text, Vasya is using the text editor. He has already written n lines, the i-th line contains ai characters (including spaces). If some line contains k characters, then this line overall contains (kβ+β1) positions where the cursor can stand: before some character or after all characters (at the end of the line). Thus, the cursor's position is determined by a pair of integers (r,βc), where r is the number of the line and c is the cursor's position in the line (the positions are indexed starting from one from the beginning of the line).Vasya doesn't use the mouse to move the cursor. He uses keys "Up", "Down", "Right" and "Left". When he pushes each of these keys, the cursor shifts in the needed direction. Let's assume that before the corresponding key is pressed, the cursor was located in the position (r,βc), then Vasya pushed key: "Up": if the cursor was located in the first line (rβ=β1), then it does not move. Otherwise, it moves to the previous line (with number rβ-β1), to the same position. At that, if the previous line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number rβ-β1; "Down": if the cursor was located in the last line (rβ=βn), then it does not move. Otherwise, it moves to the next line (with number rβ+β1), to the same position. At that, if the next line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number rβ+β1; "Right": if the cursor can move to the right in this line (cβ<βarβ+β1), then it moves to the right (to position cβ+β1). Otherwise, it is located at the end of the line and doesn't move anywhere when Vasya presses the "Right" key; "Left": if the cursor can move to the left in this line (cβ>β1), then it moves to the left (to position cβ-β1). Otherwise, it is located at the beginning of the line and doesn't move anywhere when Vasya presses the "Left" key.You've got the number of lines in the text file and the number of characters, written in each line of this file. Find the least number of times Vasya should push the keys, described above, to shift the cursor from position (r1,βc1) to position (r2,βc2). | Print a single integer β the minimum number of times Vasya should push a key to move the cursor from position (r1,βc1) to position (r2,βc2). | C | d02e8f3499c4eca03e0ae9c23f80dc95 | f00a075eec6879ac246b786365be5f94 | GNU C | output.txt | 256 megabytes | train_000.jsonl | [
"greedy",
"graphs",
"shortest paths",
"data structures",
"dfs and similar"
] | 1354960800 | ["4\n2 1 6 4\n3 4 4 2", "4\n10 5 6 4\n1 11 4 2", "3\n10 1 10\n1 10 1 1"] | NoteIn the first sample the editor contains four lines. Let's represent the cursor's possible positions in the line as numbers. Letter s represents the cursor's initial position, letter t represents the last one. Then all possible positions of the cursor in the text editor are described by the following table.12312123s5671t345One of the possible answers in the given sample is: "Left", "Down", "Left". | PASSED | 1,600 | input.txt | 1 second | The first line of the input contains an integer n (1ββ€βnββ€β100) β the number of lines in the file. The second line contains n integers a1,βa2,β...,βan (0ββ€βaiββ€β105), separated by single spaces. The third line contains four integers r1,βc1,βr2,βc2 (1ββ€βr1,βr2ββ€βn,β1ββ€βc1ββ€βar1β+β1,β1ββ€βc2ββ€βar2β+β1). | ["3", "6", "3"] | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define qlen 400000
int q[qlen][2], dr[] = {-1, 0, 1, 0}, dc[] = {0, 1, 0, -1};
int main() {
int n, *x, i, j, r, c, R, C, r_target, c_target;
int **dist, tail = 0, head = 1;
FILE *f_in = fopen("input.txt", "r");
FILE *f_out = fopen("output.txt", "w");
fscanf(f_in, " %d", &n);
x = (int *) malloc(n*sizeof(int));
dist = (int **) malloc(n*sizeof(int *));
for (i = 0; i < n; i++) {
fscanf(f_in, " %d", &x[i]);
dist[i] = (int *) malloc((x[i]+1)*sizeof(int));
for (j = 0; j <= x[i]; j++)
dist[i][j] = 100*1000*1000;
}
fscanf(f_in, " %d %d %d %d", &r, &c, &r_target, &c_target);
dist[r-1][c-1] = 0;
q[tail][0] = r-1;
q[tail][1] = c-1;
while (tail != head) {
r = q[tail][0];
c = q[tail][1];
tail = (tail+1)%qlen;
for (i = 0; i < 4; i++) {
R = r+dr[i];
C = c+dc[i];
if (R < 0 || R >= n || C < 0)
continue;
if (C > x[R])
C = x[R];
if (dist[R][C] <= dist[r][c]+1)
continue;
dist[R][C] = dist[r][c]+1;
q[head][0] = R;
q[head][1] = C;
head = (head+1)%qlen;
}
}
fprintf(f_out, "%d\n", dist[r_target-1][c_target-1]);
fflush(f_out);
return 0;
}
| |
Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher that he isn't going to become a writer? In fact, he is going to become a programmer. So, he would take great pleasure in writing a program, but none β in writing a composition.As Vasya was fishing for a sentence in the dark pond of his imagination, he suddenly wondered: what is the least number of times he should push a key to shift the cursor from one position to another one?Let's describe his question more formally: to type a text, Vasya is using the text editor. He has already written n lines, the i-th line contains ai characters (including spaces). If some line contains k characters, then this line overall contains (kβ+β1) positions where the cursor can stand: before some character or after all characters (at the end of the line). Thus, the cursor's position is determined by a pair of integers (r,βc), where r is the number of the line and c is the cursor's position in the line (the positions are indexed starting from one from the beginning of the line).Vasya doesn't use the mouse to move the cursor. He uses keys "Up", "Down", "Right" and "Left". When he pushes each of these keys, the cursor shifts in the needed direction. Let's assume that before the corresponding key is pressed, the cursor was located in the position (r,βc), then Vasya pushed key: "Up": if the cursor was located in the first line (rβ=β1), then it does not move. Otherwise, it moves to the previous line (with number rβ-β1), to the same position. At that, if the previous line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number rβ-β1; "Down": if the cursor was located in the last line (rβ=βn), then it does not move. Otherwise, it moves to the next line (with number rβ+β1), to the same position. At that, if the next line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number rβ+β1; "Right": if the cursor can move to the right in this line (cβ<βarβ+β1), then it moves to the right (to position cβ+β1). Otherwise, it is located at the end of the line and doesn't move anywhere when Vasya presses the "Right" key; "Left": if the cursor can move to the left in this line (cβ>β1), then it moves to the left (to position cβ-β1). Otherwise, it is located at the beginning of the line and doesn't move anywhere when Vasya presses the "Left" key.You've got the number of lines in the text file and the number of characters, written in each line of this file. Find the least number of times Vasya should push the keys, described above, to shift the cursor from position (r1,βc1) to position (r2,βc2). | Print a single integer β the minimum number of times Vasya should push a key to move the cursor from position (r1,βc1) to position (r2,βc2). | C | d02e8f3499c4eca03e0ae9c23f80dc95 | b4342969abf0f297998e6039f73f9d8d | GNU C | output.txt | 256 megabytes | train_000.jsonl | [
"greedy",
"graphs",
"shortest paths",
"data structures",
"dfs and similar"
] | 1354960800 | ["4\n2 1 6 4\n3 4 4 2", "4\n10 5 6 4\n1 11 4 2", "3\n10 1 10\n1 10 1 1"] | NoteIn the first sample the editor contains four lines. Let's represent the cursor's possible positions in the line as numbers. Letter s represents the cursor's initial position, letter t represents the last one. Then all possible positions of the cursor in the text editor are described by the following table.12312123s5671t345One of the possible answers in the given sample is: "Left", "Down", "Left". | PASSED | 1,600 | input.txt | 1 second | The first line of the input contains an integer n (1ββ€βnββ€β100) β the number of lines in the file. The second line contains n integers a1,βa2,β...,βan (0ββ€βaiββ€β105), separated by single spaces. The third line contains four integers r1,βc1,βr2,βc2 (1ββ€βr1,βr2ββ€βn,β1ββ€βc1ββ€βar1β+β1,β1ββ€βc2ββ€βar2β+β1). | ["3", "6", "3"] | #include<stdio.h>
//#include<string.h>
//#include<stdlib.h>
int max(int a,int b)
{
return (a>b)?a:b;
}
int min(int a,int b)
{
return (a<b)?a:b;
}
int main()
{
FILE *fin = fopen ("input.txt", "r");
FILE *fout = fopen ("output.txt", "w");
int i,j,n,a[111111],x1,y1,x2,y2,casex,minx,maxx,miny,maxy,tt1,tt,t,ans=0;
fscanf(fin,"%d",&n);
for(i=1;i<=n;i++)
{fscanf(fin,"%d",&a[i]);a[i]++;}
fscanf(fin,"%d%d%d%d",&x1,&y1,&x2,&y2);
if(x1>x2)
{
x1=n-x1;
x2=n-x2;
for(i=1;i<=n/2;i++)
{
t=a[i];a[i]=a[n-i];a[n-i]=t;
}
}
tt=y1;
for(i=x1+1;i<=x2;i++)
tt=min(tt,a[i]);
ans=x2-x1;
t=tt-y2;
tt1=tt;
//printf("%d___%d___",ans,t);
if(t<=0)
ans-=t;
else
{
for(i=x2+1;i<=n;i++)
if(a[i]<tt)
{
tt=a[i];
if(tt<=y2)
{
t=min(t,2*(i-x2)+(y2-tt));
break;
}
else
{
t=min(t,2*(i-x2)+(tt-y2));
}
}
for(i=x1-1;i>=1;i--)
if(a[i]<tt1)
{
tt1=a[i];
if(tt1<=y2)
{
t=min(t,2*(x1-i)+(y2-tt1));
break;
}
else
{
t=min(t,2*(x1-i)+(tt1-y2));
}
}
ans+=t;
}
fprintf(fout,"%d\n",ans);
//system("pause");
return 0;
}
| |
Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher that he isn't going to become a writer? In fact, he is going to become a programmer. So, he would take great pleasure in writing a program, but none β in writing a composition.As Vasya was fishing for a sentence in the dark pond of his imagination, he suddenly wondered: what is the least number of times he should push a key to shift the cursor from one position to another one?Let's describe his question more formally: to type a text, Vasya is using the text editor. He has already written n lines, the i-th line contains ai characters (including spaces). If some line contains k characters, then this line overall contains (kβ+β1) positions where the cursor can stand: before some character or after all characters (at the end of the line). Thus, the cursor's position is determined by a pair of integers (r,βc), where r is the number of the line and c is the cursor's position in the line (the positions are indexed starting from one from the beginning of the line).Vasya doesn't use the mouse to move the cursor. He uses keys "Up", "Down", "Right" and "Left". When he pushes each of these keys, the cursor shifts in the needed direction. Let's assume that before the corresponding key is pressed, the cursor was located in the position (r,βc), then Vasya pushed key: "Up": if the cursor was located in the first line (rβ=β1), then it does not move. Otherwise, it moves to the previous line (with number rβ-β1), to the same position. At that, if the previous line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number rβ-β1; "Down": if the cursor was located in the last line (rβ=βn), then it does not move. Otherwise, it moves to the next line (with number rβ+β1), to the same position. At that, if the next line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number rβ+β1; "Right": if the cursor can move to the right in this line (cβ<βarβ+β1), then it moves to the right (to position cβ+β1). Otherwise, it is located at the end of the line and doesn't move anywhere when Vasya presses the "Right" key; "Left": if the cursor can move to the left in this line (cβ>β1), then it moves to the left (to position cβ-β1). Otherwise, it is located at the beginning of the line and doesn't move anywhere when Vasya presses the "Left" key.You've got the number of lines in the text file and the number of characters, written in each line of this file. Find the least number of times Vasya should push the keys, described above, to shift the cursor from position (r1,βc1) to position (r2,βc2). | Print a single integer β the minimum number of times Vasya should push a key to move the cursor from position (r1,βc1) to position (r2,βc2). | C | d02e8f3499c4eca03e0ae9c23f80dc95 | a6cbecd7db5fa5f0bb2dc98455df0b78 | GNU C | output.txt | 256 megabytes | train_000.jsonl | [
"greedy",
"graphs",
"shortest paths",
"data structures",
"dfs and similar"
] | 1354960800 | ["4\n2 1 6 4\n3 4 4 2", "4\n10 5 6 4\n1 11 4 2", "3\n10 1 10\n1 10 1 1"] | NoteIn the first sample the editor contains four lines. Let's represent the cursor's possible positions in the line as numbers. Letter s represents the cursor's initial position, letter t represents the last one. Then all possible positions of the cursor in the text editor are described by the following table.12312123s5671t345One of the possible answers in the given sample is: "Left", "Down", "Left". | PASSED | 1,600 | input.txt | 1 second | The first line of the input contains an integer n (1ββ€βnββ€β100) β the number of lines in the file. The second line contains n integers a1,βa2,β...,βan (0ββ€βaiββ€β105), separated by single spaces. The third line contains four integers r1,βc1,βr2,βc2 (1ββ€βr1,βr2ββ€βn,β1ββ€βc1ββ€βar1β+β1,β1ββ€βc2ββ€βar2β+β1). | ["3", "6", "3"] | #include <stdio.h>
int linfc, colfc;
int menor(int a, int b)
{
if(a>b)
return b;
return a;
}
int modulo(int a, int b)
{
if(a>b)
return a-b;
return b-a;
}
int resolve(int linic, int colic, int mov1, int car[], int up)
{
mov1+=modulo(linic, linfc);
while(linic!=linfc)
{
if(car[linic+up]+1<colic)
colic = car[linic+up]+1;
linic+=up;
}
mov1+=modulo(colic, colfc);
return mov1;
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int n, linic, colic, i, j, mov, car[105], minimo, menorcol, movat, up;
scanf(" %d", &n);
for(i=1;i<=n;i++)
scanf(" %d", &car[i]);
scanf(" %d %d %d %d", &linic, &colic, &linfc, &colfc);
if(linic > linfc)
up=-1;
else
up=1;
minimo = resolve(linic, colic, 0, car, up);
menorcol = colic;
for(i=-up;linic+i>0 && linic+i <= n;i+=-up)
{
menorcol = menor( menorcol, car[linic+i]+1);
minimo = menor(minimo, resolve(linic+i, menorcol, modulo(i, 0), car, up));
}
movat=modulo(linic, linfc);
while(linic!=linfc)
{
if(car[linic+up]+1<colic)
colic = car[linic+up]+1;
linic+=up;
}
menorcol = colic;
for(i=up;linic+i>0 && linic+i <= n;i+=up)
{
menorcol = menor( menorcol, car[linic+i]+1);
minimo = menor(minimo, resolve(linic+i, menorcol, movat+modulo(i, 0), car, -up));
}
printf("%d", minimo);
getchar();
getchar();
return 0;
}
| |
Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher that he isn't going to become a writer? In fact, he is going to become a programmer. So, he would take great pleasure in writing a program, but none β in writing a composition.As Vasya was fishing for a sentence in the dark pond of his imagination, he suddenly wondered: what is the least number of times he should push a key to shift the cursor from one position to another one?Let's describe his question more formally: to type a text, Vasya is using the text editor. He has already written n lines, the i-th line contains ai characters (including spaces). If some line contains k characters, then this line overall contains (kβ+β1) positions where the cursor can stand: before some character or after all characters (at the end of the line). Thus, the cursor's position is determined by a pair of integers (r,βc), where r is the number of the line and c is the cursor's position in the line (the positions are indexed starting from one from the beginning of the line).Vasya doesn't use the mouse to move the cursor. He uses keys "Up", "Down", "Right" and "Left". When he pushes each of these keys, the cursor shifts in the needed direction. Let's assume that before the corresponding key is pressed, the cursor was located in the position (r,βc), then Vasya pushed key: "Up": if the cursor was located in the first line (rβ=β1), then it does not move. Otherwise, it moves to the previous line (with number rβ-β1), to the same position. At that, if the previous line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number rβ-β1; "Down": if the cursor was located in the last line (rβ=βn), then it does not move. Otherwise, it moves to the next line (with number rβ+β1), to the same position. At that, if the next line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number rβ+β1; "Right": if the cursor can move to the right in this line (cβ<βarβ+β1), then it moves to the right (to position cβ+β1). Otherwise, it is located at the end of the line and doesn't move anywhere when Vasya presses the "Right" key; "Left": if the cursor can move to the left in this line (cβ>β1), then it moves to the left (to position cβ-β1). Otherwise, it is located at the beginning of the line and doesn't move anywhere when Vasya presses the "Left" key.You've got the number of lines in the text file and the number of characters, written in each line of this file. Find the least number of times Vasya should push the keys, described above, to shift the cursor from position (r1,βc1) to position (r2,βc2). | Print a single integer β the minimum number of times Vasya should push a key to move the cursor from position (r1,βc1) to position (r2,βc2). | C | d02e8f3499c4eca03e0ae9c23f80dc95 | 900384dbcde0cc1df7df911f9f969190 | GNU C | output.txt | 256 megabytes | train_000.jsonl | [
"greedy",
"graphs",
"shortest paths",
"data structures",
"dfs and similar"
] | 1354960800 | ["4\n2 1 6 4\n3 4 4 2", "4\n10 5 6 4\n1 11 4 2", "3\n10 1 10\n1 10 1 1"] | NoteIn the first sample the editor contains four lines. Let's represent the cursor's possible positions in the line as numbers. Letter s represents the cursor's initial position, letter t represents the last one. Then all possible positions of the cursor in the text editor are described by the following table.12312123s5671t345One of the possible answers in the given sample is: "Left", "Down", "Left". | PASSED | 1,600 | input.txt | 1 second | The first line of the input contains an integer n (1ββ€βnββ€β100) β the number of lines in the file. The second line contains n integers a1,βa2,β...,βan (0ββ€βaiββ€β105), separated by single spaces. The third line contains four integers r1,βc1,βr2,βc2 (1ββ€βr1,βr2ββ€βn,β1ββ€βc1ββ€βar1β+β1,β1ββ€βc2ββ€βar2β+β1). | ["3", "6", "3"] | #include <stdio.h>
int d[100][100001];
int used[100][100001];
int lenght[100];
struct step
{
int r;
int c;
} queue[100 * 100001];
int qh = 0, qt = 0;
void add(int r, int c)
{
queue[qh].r = r;
queue[qh].c = c;
qh++;
}
struct step get()
{
qt++;
return queue[qt - 1];
}
int min(int a, int b)
{
return (a < b) ? a : b;
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int n, c1, r1, c2, r2;
scanf("%d\n", &n);
int i, j, z;
for(i = 0; i < n; i++)
{
scanf("%d ", &lenght[i]);
}
scanf("\n%d %d %d %d", &r1, &c1, &r2, &c2);
d[r1 - 1][c1 - 1] = 0;
used[r1 - 1][c1 - 1] = 1;
add(r1 - 1, c1 - 1);
struct step buf;
while(qt < qh)
{
buf = get();
if(buf.c < lenght[buf.r] && !used[buf.r][buf.c + 1])
{
used[buf.r][buf.c + 1] = 1;
d[buf.r][buf.c + 1] = d[buf.r][buf.c] + 1;
add(buf.r, buf.c + 1);
}
if(buf.c > 0 && !used[buf.r][buf.c - 1])
{
used[buf.r][buf.c - 1] = 1;
d[buf.r][buf.c - 1] = d[buf.r][buf.c] + 1;
add(buf.r, buf.c - 1);
}
if(buf.r > 0 && !used[buf.r - 1][min(buf.c, lenght[buf.r - 1])])
{
used[buf.r - 1][min(buf.c, lenght[buf.r - 1])] = 1;
d[buf.r - 1][min(buf.c, lenght[buf.r - 1])] = d[buf.r][buf.c] + 1;
add(buf.r - 1, min(buf.c, lenght[buf.r - 1]));
}
if(buf.r < n - 1 && !used[buf.r + 1][min(buf.c, lenght[buf.r + 1])])
{
used[buf.r + 1][min(buf.c, lenght[buf.r + 1])] = 1;
d[buf.r + 1][min(buf.c, lenght[buf.r + 1])] = d[buf.r][buf.c] + 1;
add(buf.r + 1, min(buf.c, lenght[buf.r + 1]));
}
}
printf("%d", d[r2 - 1][c2 - 1]);
return 0;
} | |
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ β length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_2 + a_3 - a_4 + \dotsc = 0$$$). In other words, Alexandra wants sum of all elements at the odd positions and sum of all elements at the even positions to become equal. The elements that you remove don't have to be consecutive.For example, if she has $$$a = [1, 0, 1, 0, 0, 0]$$$ and she removes $$$2$$$nd and $$$4$$$th elements, $$$a$$$ will become equal $$$[1, 1, 0, 0]$$$ and its alternating sum is $$$1 - 1 + 0 - 0 = 0$$$.Help her! | For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) β number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If there are several answers, you can output any of them. | C | eca92beb189c4788e8c4744af1428bc7 | 36e8631a5dfbdf5f9d343444622f377e | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"constructive algorithms",
"math"
] | 1599575700 | ["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"] | NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything. | PASSED | 1,100 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) Β β length of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 1$$$) Β β elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^3$$$. | ["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"] | #include <stdio.h>
#include <stdlib.h>
long long int min(long long int a,long long int b)
{
if(a<=b)
return(a);
else
return(b);
}
int main()
{
int t,i;
scanf("%d",&t);
for(i=0;i<t;i++)
{
int n,o=0,z=0,k=0,f=0,mp=0;scanf("%d",&n);int a[n],j;for(j=0;j<n;j++)scanf("%d",(a+j));
for(j=0;j<n;j++)
{
if(a[j]==0)
while(a[j]==0&&(j<n))
{
mp++;j++;
}
}
for(j=0;j<n;j++){if(a[j]==0)z++;else o++;}
int z1=0,o1=0;
for(j=0;j<n;j++)
{
if((a[j]==0)&&(k==0)&&(f%2==0))
{
k++;
}
else if((f<((n/2)-1))&&(a[j]==1))
{
f++;
}
}
if((n==2)&&(z==1))
{
printf("1\n0\n");continue;
}
if(n==2)
{
printf("%d\n",n);printf("%d %d\n",a[0],a[1]);continue;
}
if(z>(n/2))
{
if(((n/2)%2)==0)
printf("%d\n",n/2);
else
printf("%d\n",(n/2)+1);
for(j=0;j<(n/2);j++)
printf("0 ");
if((n/2)%2==1)
printf("0 ");
printf("\n");continue;
}
if(o>(n/2))
{
if(((n/2)%2)==0)
printf("%d\n",n/2);
else
printf("%d\n",(n/2)+1);
for(j=0;j<(n/2);j++)
printf("1 ");
if((n/2)%2==1)
printf("1 ");
printf("\n");continue;
}
else
{
if((n/2)%2==0)
{
printf("%d\n",n/2);
for(j=0;j<n/2;j++)
printf("1 ");
printf("\n");continue;
}
if(mp==(n/2))
{
printf("%d\n",(n/2));
for(j=0;j<(n/2);j++)
printf("0 ");
printf("\n");continue;
}
else
{
if(k!=0)
{
int u=0,f=0;
printf("%d\n",(n/2));
for(j=0;j<n;j++)
{
if((a[j]==0)&&(u==0)&&(f%2==0))
{
u++;printf("%d ",a[j]);
}
else if((f<((n/2)-1))&&(a[j]==1))
{
f++;printf("%d ",a[j]);
}
}
printf("\n");continue;
}
else
{
int u=0,f=0;
printf("%d\n",n/2);
for(j=0;j<n;j++)
{
if((a[j]==0)&&(u<=1)&&(a[j]!=a[j-1]))
{
u++;printf("%d ",a[j]);
}
else if((f<((n/2)-2))&&(a[j]==1))
{
f++;printf("%d ",a[j]);
}
}
}
}
}
}
return 0;
}
| |
Alexandra has an even-length array $$$a$$$, consisting of $$$0$$$s and $$$1$$$s. The elements of the array are enumerated from $$$1$$$ to $$$n$$$. She wants to remove at most $$$\frac{n}{2}$$$ elements (where $$$n$$$ β length of array) in the way that alternating sum of the array will be equal $$$0$$$ (i.e. $$$a_1 - a_2 + a_3 - a_4 + \dotsc = 0$$$). In other words, Alexandra wants sum of all elements at the odd positions and sum of all elements at the even positions to become equal. The elements that you remove don't have to be consecutive.For example, if she has $$$a = [1, 0, 1, 0, 0, 0]$$$ and she removes $$$2$$$nd and $$$4$$$th elements, $$$a$$$ will become equal $$$[1, 1, 0, 0]$$$ and its alternating sum is $$$1 - 1 + 0 - 0 = 0$$$.Help her! | For each test case, firstly, print $$$k$$$ ($$$\frac{n}{2} \leq k \leq n$$$) β number of elements that will remain after removing in the order they appear in $$$a$$$. Then, print this $$$k$$$ numbers. Note that you should print the numbers themselves, not their indices. We can show that an answer always exists. If there are several answers, you can output any of them. | C | eca92beb189c4788e8c4744af1428bc7 | e0fbdd666baa82a5b9327a855eb41a74 | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"constructive algorithms",
"math"
] | 1599575700 | ["4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0"] | NoteIn the first and second cases, alternating sum of the array, obviously, equals $$$0$$$.In the third case, alternating sum of the array equals $$$1 - 1 = 0$$$.In the fourth case, alternating sum already equals $$$1 - 1 + 0 - 0 = 0$$$, so we don't have to remove anything. | PASSED | 1,100 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^3$$$, $$$n$$$ is even) Β β length of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 1$$$) Β β elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^3$$$. | ["1\n0\n1\n0\n2\n1 1\n4\n1 1 0 0"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
int a[n+1],i,k=0,k_=0,p,m;
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]==1)
k++;
else
k_++;
}
p=n/2;
if(k_>=n/2){
printf("%d\n",n/2);
for(i=1;i<=n/2;i++)
printf("0 ");
}
else if(k>n/2)
{
if(p%2)
p+=1;
printf("%d\n",p);
for(i=1;i<=p;i++)
printf("1 ");
}
printf("\n");
}
}
| |
The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness".The test consists of n questions; the questions are to be answered strictly in the order in which they are given, from question 1 to question n. Question i contains ai answer variants, exactly one of them is correct. A click is regarded as selecting any answer in any question. The goal is to select the correct answer for each of the n questions. If Vaganych selects a wrong answer for some question, then all selected answers become unselected and the test starts from the very beginning, from question 1 again. But Vaganych remembers everything. The order of answers for each question and the order of questions remain unchanged, as well as the question and answers themselves.Vaganych is very smart and his memory is superb, yet he is unbelievably unlucky and knows nothing whatsoever about the test's theme. How many clicks will he have to perform in the worst case? | Print a single number β the minimal number of clicks needed to pass the test it the worst-case scenario. Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator. | C | c8531b2ab93993b2c3467595ad0679c5 | 78a1b4bfd610160f30945a548a47e09f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"math"
] | 1312714800 | ["2\n1 1", "2\n2 2", "1\n10"] | NoteNote to the second sample. In the worst-case scenario you will need five clicks: the first click selects the first variant to the first question, this answer turns out to be wrong. the second click selects the second variant to the first question, it proves correct and we move on to the second question; the third click selects the first variant to the second question, it is wrong and we go back to question 1; the fourth click selects the second variant to the first question, it proves as correct as it was and we move on to the second question; the fifth click selects the second variant to the second question, it proves correct, the test is finished. | PASSED | 1,100 | standard input | 2 seconds | The first line contains a positive integer n (1ββ€βnββ€β100). It is the number of questions in the test. The second line contains space-separated n positive integers ai (1ββ€βaiββ€β109), the number of answer variants to question i. | ["2", "5", "10"] | #include <stdio.h>
int main()
{
int n,i,a;
long long res = 0;
scanf("%d",&n);
for(i=0;i<n;++i)
{
scanf("%d",&a);
res += (a-1)*(long long)(i+1) + 1;
}
printf("%I64d\n",res);
return 0;
}
| |
The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness".The test consists of n questions; the questions are to be answered strictly in the order in which they are given, from question 1 to question n. Question i contains ai answer variants, exactly one of them is correct. A click is regarded as selecting any answer in any question. The goal is to select the correct answer for each of the n questions. If Vaganych selects a wrong answer for some question, then all selected answers become unselected and the test starts from the very beginning, from question 1 again. But Vaganych remembers everything. The order of answers for each question and the order of questions remain unchanged, as well as the question and answers themselves.Vaganych is very smart and his memory is superb, yet he is unbelievably unlucky and knows nothing whatsoever about the test's theme. How many clicks will he have to perform in the worst case? | Print a single number β the minimal number of clicks needed to pass the test it the worst-case scenario. Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator. | C | c8531b2ab93993b2c3467595ad0679c5 | 42436abcb1cb0677471cfcf1ad880ff1 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"math"
] | 1312714800 | ["2\n1 1", "2\n2 2", "1\n10"] | NoteNote to the second sample. In the worst-case scenario you will need five clicks: the first click selects the first variant to the first question, this answer turns out to be wrong. the second click selects the second variant to the first question, it proves correct and we move on to the second question; the third click selects the first variant to the second question, it is wrong and we go back to question 1; the fourth click selects the second variant to the first question, it proves as correct as it was and we move on to the second question; the fifth click selects the second variant to the second question, it proves correct, the test is finished. | PASSED | 1,100 | standard input | 2 seconds | The first line contains a positive integer n (1ββ€βnββ€β100). It is the number of questions in the test. The second line contains space-separated n positive integers ai (1ββ€βaiββ€β109), the number of answer variants to question i. | ["2", "5", "10"] | #include<stdio.h>
int main()
{
long long n,m,i,s=0;
scanf("%I64d",&n);
for(i=0;i<n;i++)
{
scanf("%I64d",&m);
s+=(((m-1)*(i+1))+1);
}
printf("%I64d\n",s);
return 0;
}
| |
The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness".The test consists of n questions; the questions are to be answered strictly in the order in which they are given, from question 1 to question n. Question i contains ai answer variants, exactly one of them is correct. A click is regarded as selecting any answer in any question. The goal is to select the correct answer for each of the n questions. If Vaganych selects a wrong answer for some question, then all selected answers become unselected and the test starts from the very beginning, from question 1 again. But Vaganych remembers everything. The order of answers for each question and the order of questions remain unchanged, as well as the question and answers themselves.Vaganych is very smart and his memory is superb, yet he is unbelievably unlucky and knows nothing whatsoever about the test's theme. How many clicks will he have to perform in the worst case? | Print a single number β the minimal number of clicks needed to pass the test it the worst-case scenario. Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator. | C | c8531b2ab93993b2c3467595ad0679c5 | bc4db74b89e46ad5098925385aff0cd0 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"math"
] | 1312714800 | ["2\n1 1", "2\n2 2", "1\n10"] | NoteNote to the second sample. In the worst-case scenario you will need five clicks: the first click selects the first variant to the first question, this answer turns out to be wrong. the second click selects the second variant to the first question, it proves correct and we move on to the second question; the third click selects the first variant to the second question, it is wrong and we go back to question 1; the fourth click selects the second variant to the first question, it proves as correct as it was and we move on to the second question; the fifth click selects the second variant to the second question, it proves correct, the test is finished. | PASSED | 1,100 | standard input | 2 seconds | The first line contains a positive integer n (1ββ€βnββ€β100). It is the number of questions in the test. The second line contains space-separated n positive integers ai (1ββ€βaiββ€β109), the number of answer variants to question i. | ["2", "5", "10"] | #include <stdio.h>
int main()
{
long long int n, i, a[101], ans;
scanf("%lld", &n);
for(i=0; i<n; i++)
scanf("%lld", &a[i]);
ans=a[0];
for(i=1; i<n; i++)
ans+=(a[i]+(a[i]-1)*i);
printf("%lld", ans);
return 0;
} | |
The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness".The test consists of n questions; the questions are to be answered strictly in the order in which they are given, from question 1 to question n. Question i contains ai answer variants, exactly one of them is correct. A click is regarded as selecting any answer in any question. The goal is to select the correct answer for each of the n questions. If Vaganych selects a wrong answer for some question, then all selected answers become unselected and the test starts from the very beginning, from question 1 again. But Vaganych remembers everything. The order of answers for each question and the order of questions remain unchanged, as well as the question and answers themselves.Vaganych is very smart and his memory is superb, yet he is unbelievably unlucky and knows nothing whatsoever about the test's theme. How many clicks will he have to perform in the worst case? | Print a single number β the minimal number of clicks needed to pass the test it the worst-case scenario. Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator. | C | c8531b2ab93993b2c3467595ad0679c5 | 136dd50eefc9a34c3f27447cdb73ef75 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"math"
] | 1312714800 | ["2\n1 1", "2\n2 2", "1\n10"] | NoteNote to the second sample. In the worst-case scenario you will need five clicks: the first click selects the first variant to the first question, this answer turns out to be wrong. the second click selects the second variant to the first question, it proves correct and we move on to the second question; the third click selects the first variant to the second question, it is wrong and we go back to question 1; the fourth click selects the second variant to the first question, it proves as correct as it was and we move on to the second question; the fifth click selects the second variant to the second question, it proves correct, the test is finished. | PASSED | 1,100 | standard input | 2 seconds | The first line contains a positive integer n (1ββ€βnββ€β100). It is the number of questions in the test. The second line contains space-separated n positive integers ai (1ββ€βaiββ€β109), the number of answer variants to question i. | ["2", "5", "10"] | #include<stdio.h>
int main()
{
int i,n,m;
scanf("%d",&n);
m=n;i=0;
long long int a[100],final=0;
while(m--)
{
scanf("%lld",&a[i]);
final=final+(a[i]-1)*(i+1)+1;
// printf("%lu\n",final);
i++;
}
printf("%lld\n",final);
return 0;
}
| |
The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness".The test consists of n questions; the questions are to be answered strictly in the order in which they are given, from question 1 to question n. Question i contains ai answer variants, exactly one of them is correct. A click is regarded as selecting any answer in any question. The goal is to select the correct answer for each of the n questions. If Vaganych selects a wrong answer for some question, then all selected answers become unselected and the test starts from the very beginning, from question 1 again. But Vaganych remembers everything. The order of answers for each question and the order of questions remain unchanged, as well as the question and answers themselves.Vaganych is very smart and his memory is superb, yet he is unbelievably unlucky and knows nothing whatsoever about the test's theme. How many clicks will he have to perform in the worst case? | Print a single number β the minimal number of clicks needed to pass the test it the worst-case scenario. Please do not use the %lld specificator to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specificator. | C | c8531b2ab93993b2c3467595ad0679c5 | 90b070dc0412281e917b72affa25a877 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"greedy",
"math"
] | 1312714800 | ["2\n1 1", "2\n2 2", "1\n10"] | NoteNote to the second sample. In the worst-case scenario you will need five clicks: the first click selects the first variant to the first question, this answer turns out to be wrong. the second click selects the second variant to the first question, it proves correct and we move on to the second question; the third click selects the first variant to the second question, it is wrong and we go back to question 1; the fourth click selects the second variant to the first question, it proves as correct as it was and we move on to the second question; the fifth click selects the second variant to the second question, it proves correct, the test is finished. | PASSED | 1,100 | standard input | 2 seconds | The first line contains a positive integer n (1ββ€βnββ€β100). It is the number of questions in the test. The second line contains space-separated n positive integers ai (1ββ€βaiββ€β109), the number of answer variants to question i. | ["2", "5", "10"] | #include <stdio.h>
main()
{
unsigned long long int n, a[101], w, i=1;
scanf("%I64d", &n);
w=n;
L: if (i<=n)
{
scanf("%I64d", &a[i]);
i++;
goto L;
}
i=1;
M: if (i<=n)
{
w=w+i*(a[i]-1);
i++;
goto M;
}
printf("%I64d", w);
return 0;
}
| |
Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhail to convince the scientific community in this!Let us remind you that a number is called prime if it is integer larger than one, and is not divisible by any positive integer other than itself and one.Rikhail calls a number a palindromic if it is integer, positive, and its decimal representation without leading zeros is a palindrome, i.e. reads the same from left to right and right to left.One problem with prime numbers is that there are too many of them. Let's introduce the following notation: Ο(n)Β β the number of primes no larger than n, rub(n)Β β the number of palindromic numbers no larger than n. Rikhail wants to prove that there are a lot more primes than palindromic ones.He asked you to solve the following problem: for a given value of the coefficient A find the maximum n, such that Ο(n)ββ€βAΒ·rub(n). | If such maximum number exists, then print it. Otherwise, print "Palindromic tree is better than splay tree" (without the quotes). | C | e6e760164882b9e194a17663625be27d | 2a237a0ce1b53ac20f880ffb23fa180d | GNU C11 | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"number theory",
"brute force",
"math"
] | 1439224200 | ["1 1", "1 42", "6 4"] | null | PASSED | 1,600 | standard input | 3 seconds | The input consists of two positive integers p, q, the numerator and denominator of the fraction that is the value of AΒ (,Β ). | ["40", "1", "172"] | /* practice with Dukkha */
#include <stdio.h>
#define N 1179858
int dd[8];
int palin(int n) {
int k, i, j;
k = 0;
while (n > 0) {
dd[k++] = n % 10;
n /= 10;
}
for (i = 0, j = k - 1; i < j; i++, j--)
if (dd[i] != dd[j])
return 0;
return 1;
}
int main() {
static int kk[N + 1], ll[N + 1];
int p, q, n, l, a, b;
scanf("%d%d", &p, &q);
for (a = 2; a <= N; a++)
kk[a] = 1;
kk[0] = kk[1] = 0;
for (a = 2; a <= N; a++) {
if (kk[a] == 0) {
kk[a] += kk[a - 1];
continue;
}
kk[a] += kk[a - 1];
for (b = a + a; b <= N; b += a)
kk[b] = 0;
}
l = 0;
for (n = 1; n <= N; n++) {
if (palin(n))
l++;
ll[n] = l;
}
for (n = N; n >= 0; n--)
if ((long long) kk[n] * q <= (long long) p * ll[n]) {
printf("%d\n", n);
return 0;
}
return 0;
}
| |
Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhail to convince the scientific community in this!Let us remind you that a number is called prime if it is integer larger than one, and is not divisible by any positive integer other than itself and one.Rikhail calls a number a palindromic if it is integer, positive, and its decimal representation without leading zeros is a palindrome, i.e. reads the same from left to right and right to left.One problem with prime numbers is that there are too many of them. Let's introduce the following notation: Ο(n)Β β the number of primes no larger than n, rub(n)Β β the number of palindromic numbers no larger than n. Rikhail wants to prove that there are a lot more primes than palindromic ones.He asked you to solve the following problem: for a given value of the coefficient A find the maximum n, such that Ο(n)ββ€βAΒ·rub(n). | If such maximum number exists, then print it. Otherwise, print "Palindromic tree is better than splay tree" (without the quotes). | C | e6e760164882b9e194a17663625be27d | 517d273da334fa7214ff630ea099eba8 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation",
"number theory",
"brute force",
"math"
] | 1439224200 | ["1 1", "1 42", "6 4"] | null | PASSED | 1,600 | standard input | 3 seconds | The input consists of two positive integers p, q, the numerator and denominator of the fraction that is the value of AΒ (,Β ). | ["40", "1", "172"] | #include<stdio.h>
//typedef int lld;
int arr[2000010],prime[2000010],palin[2000010];
int main()
{int p,q;
//int arr[1000010];
//int prime[1000010];
int check[10];
int i;
int count=0;
int k;
int j;
for(i=1;i<2000010;i++)
arr[i]=i;
arr[1]=-1;
for(i=2;i<2000010;i++)
{if(arr[i]!=-1)
{for(j=2*i;j<2000010;j=j+i)
{ if(arr[j]!=-1)
arr[j]=-1;
}
}
}
/*for(i=1;i<100010;i++)
printf("%d\n",arr[i]);
*/
for(i=1;i<2000010;i++)
{if(arr[i]!=-1)
count++;
prime[i]=count;
}
int l;
int count1=0;
//int palin[1000010];
for(i=1;i<2000010;i++)
{k=0;
int fg=i;
while(fg>0)
{ check[k++]=fg%10;
fg=fg/10;
}
int flag=0;
for(j=0,l=k-1;j<k/2 && l>=k/2;j++,l--)
{ if(check[j]==check[l])
count++;
else
{flag=1;
break;
}
}
if(flag==0)
count1++;
palin[i]=count1;
}
// for(i=1;i<100;i++)
// printf("prime=%d palin=%d\n",prime[i],palin[i]);
scanf("%d%d",&p,&q);
float a=((float)p)/((float)q);
// printf("%f\n",a);
// printf("%d %d\n",prime[172],palin[172]);
// printf("%d %d\n",prime[40],palin[40]);
int flag1=0;
int max=-1;
for(i=1;i<2000010-1;i++)
{
float rub=a*((float)palin[i]);
// printf("%f\n",rub);
if(((float)prime[i])<=(rub) && ((float)prime[i+1])>rub)
{
//printf("%d\n",i);
if(i>max)
max=i;
flag1=1;
//break;
}
}
if(flag1==1)
printf("%d\n",max);
if(flag1==0)
printf("Palindromic tree is better than splay tree\n");
return 0;
}
| |
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other nβ-β1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want? | In a single line print a single integer β the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 09f5623c3717c9d360334500b198d8e0 | 9619fcda6f163eca5d091b3aa821196d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1380295800 | ["3\n3 2 2", "4\n2 2 2 2"] | NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game). | PASSED | 1,600 | standard input | 2 seconds | The first line contains integer n (3ββ€βnββ€β105). The second line contains n space-separated integers a1,βa2,β...,βan (1ββ€βaiββ€β109) β the i-th number in the list is the number of rounds the i-th person wants to play. | ["4", "3"] | #include<stdio.h>
int a[100005];
int main()
{
__int64 n,t,sum,mx;
int i;
sum=0;
mx=0;
scanf("%I64d",&n);
for(i=0;i<n;i++)
{
scanf("%I64d",&a[i]);
sum+=a[i];
if(a[i]>mx)
{
mx=a[i];
}
}
if(sum%(n-1)==0)
{
if(mx<sum/(n-1))mx=sum/(n-1);
printf("%I64d\n",mx);
}
else
{
if(mx<sum/(n-1)+1)mx=sum/(n-1)+1;
printf("%I64d\n",mx);
}
}
| |
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other nβ-β1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want? | In a single line print a single integer β the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 09f5623c3717c9d360334500b198d8e0 | 099c52f94e97da14df9b6e4665591db9 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1380295800 | ["3\n3 2 2", "4\n2 2 2 2"] | NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game). | PASSED | 1,600 | standard input | 2 seconds | The first line contains integer n (3ββ€βnββ€β105). The second line contains n space-separated integers a1,βa2,β...,βan (1ββ€βaiββ€β109) β the i-th number in the list is the number of rounds the i-th person wants to play. | ["4", "3"] | #include <stdio.h>
int n;
long long a[100010];
int check(long long ans) {
int i;
long long tot = 0;
for (i = 1; i <= n; i++) {
tot += (ans - a[i]);
}
if (tot >= ans) return 0;
else return 1;
}
int main() {
int i;
long long max = 0, sum = 0, l, r, mid;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &a[i]);
sum += a[i];
if (a[i] > max)
max = a[i];
}
l = max;
r = sum;
while (l < r) {
mid = (l + r) / 2;
if (check(mid))
l = mid + 1;
else r = mid;
}
printf("%I64d\n", l);
return 0;
}
| |
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other nβ-β1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want? | In a single line print a single integer β the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 09f5623c3717c9d360334500b198d8e0 | 9b8aa289c0f2dd7e14f93f594a6a6658 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1380295800 | ["3\n3 2 2", "4\n2 2 2 2"] | NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game). | PASSED | 1,600 | standard input | 2 seconds | The first line contains integer n (3ββ€βnββ€β105). The second line contains n space-separated integers a1,βa2,β...,βan (1ββ€βaiββ€β109) β the i-th number in the list is the number of rounds the i-th person wants to play. | ["4", "3"] | #include <stdio.h>
int main() {
long long int n,x,i;
scanf("%lld",&n);
long long int max=0,rem=0;
for(i=0;i<n;i++)
{
scanf("%lld",&x);
rem = rem + x;
if(max<x)
max=x;
}
long long int ans = rem/(n-1) + (rem%(n-1)==0?0:1);
if(max<ans)
printf("%lld\n",ans);
else
printf("%lld\n",max);
return 0;
}
| |
One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other nβ-β1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want? | In a single line print a single integer β the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 09f5623c3717c9d360334500b198d8e0 | 1cebf1a74eb1264b49f268dcfb24b065 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1380295800 | ["3\n3 2 2", "4\n2 2 2 2"] | NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game). | PASSED | 1,600 | standard input | 2 seconds | The first line contains integer n (3ββ€βnββ€β105). The second line contains n space-separated integers a1,βa2,β...,βan (1ββ€βaiββ€β109) β the i-th number in the list is the number of rounds the i-th person wants to play. | ["4", "3"] | #include <stdio.h>
#include <stdlib.h>
long long w[100000];
int cmp(const void *ap, const void *bp)
{
long long a = *((long long *) ap);
long long b = *((long long *) bp);
if(a == b) return 0;
return (a > b) ? 1 : -1;
}
int main()
{
int n;
register int i;
scanf("%d", &n);
for(i = 0; i < n; i++)
{
scanf("%lld", &w[i]);
}
qsort(w, n, sizeof(long long), cmp);
long long sum = 0;
for(i = 0; i < n; i++) sum += w[i];
long long buf = w[n - 1] * n - sum;
if(buf >= w[n - 1])
{
printf("%lld", w[n - 1]);
}
else
{
buf = w[n - 1] - buf;
printf("%lld", (w[n - 1] - buf) + (buf / (n - 1)) * n + ((buf % (n - 1)) ? (buf % (n - 1) + 1) : 0));
}
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 3349988814d8813089e07eff753b6fcb | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
#define MAX 100
main()
{
int n,P,Q,R,T,S,l[MAX],r[MAX],i,res=0,a,b;
scanf("%d %d %d %d %d %d",&n,&P,&Q,&R,&T,&S);
for(i=1;i<=n;i++)
{
scanf("%d %d",&l[i],&r[i]);
res+=(P*(r[i]-l[i]));
}
if(n>1)
{
for(i=2;i<=n;i++)
{
a=l[i]-r[i-1];
if(a>T)
{
res+=(P*T);
b=a-T;
if(b>=S)
res+=((Q*S)+(R*(b-S)));
else
res+=(Q*b);
}
else
res+=(P*a);
}
}
printf("%d",res);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 4f4b65d12c2332949ae8a34d1ab307ae | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <stdlib.h>
main()
{
int n,p1,p2,p3,t1,t2,i,l,r,x,y;
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
x = 0;
for (i=0;i<n;i++)
{
scanf("%d%d",&l,&r);
x = x + (p1 * (r - l));
if (0<i)
{
if (l-y<=t1) x = x + (p1 * (l - y));
else
{
x = x + (p1 * t1);
if (l-y-t1<=t2) x = x + (p2 * (l - y - t1));
else x = x + (p2 * t2) + (p3 * (l - y - t1 - t2));
}
}
y = r;
}
printf("%d",x);
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | c2d869b459ef49225c91f32ecc3df6fd | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <stdlib.h>
int main() {
int n, p1, p2, p3, t1, t2, *l, *r;
int i, sum = 0;
scanf("%d%d%d%d%d%d", &n, &p1, &p2, &p3, &t1, &t2);
l = malloc(sizeof(*l) * n);
r = malloc(sizeof(*r) * n);
for (i = 0; i < n; i++) {
scanf("%d%d", &l[i], &r[i]);
sum += (r[i] - l[i]) * p1;
}
for (i = 1; i < n; i++)
if (l[i] - r[i - 1] >= t1) {
sum += t1 * p1;
if (l[i] - r[i - 1] - t1 >= t2) {
sum += t2 * p2;
sum += (l[i] - r[i - 1] - t1 - t2) * p3;
} else
sum += (l[i] - r[i - 1] - t1) * p2;
} else
sum += (l[i] - r[i - 1]) * p1;
printf("%d\n", sum);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 7cd41194998c968a8ff7bd4a4e07b409 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n,p1,p2,p3,t1,t2,i,j;
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
int rr=-1;
int ans=0;
while(n--)
{
int l,r;
scanf("%d%d",&l,&r);
ans+=(r-l)*p1;
if(rr!=-1)
{
int d=l-rr;
if(d<t1)ans+=d*p1;
else if(d<t1+t2)ans+=t1*p1+(d-t1)*p2;
else ans+=t1*p1+t2*p2+(d-t1-t2)*p3;
}
rr=r;
}
printf("%d\n",ans);
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 62bc350e26161cda8aa2c5950653cad6 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main() {
int n,p1,p2,p3,t1,t2;
scanf("%d %d %d %d %d %d\n",&n,&p1,&p2,&p3,&t1,&t2);
int l,r;
scanf("%d %d",&l,&r);
int c=(r-l)*p1;
while (--n) {
int or=r;
scanf("%d %d",&l,&r);
c+=(r-l)*p1;
if (l-or<t1) c+=(l-or)*p1;
else {
c+=t1*p1;
if (l-or-t1<t2) c+=(l-or-t1)*p2;
else {
c+=t2*p2;
c+=(l-or-t1-t2)*p3;
}
}
}
printf("%i\n",c);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 3664a93b214e492f02c8d89e7380ebf5 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main()
{
int n, p1, p2, p3, t1, t2, l1, l2, r1, r2, a, b, c;
long int total=0;
scanf("%d %d %d %d %d %d", &n, &p1, &p2, &p3, &t1, &t2);
if(n==1){
scanf("%d %d", &l1, &r1);
}
else {
scanf("%d %d", &l1, &r1);
for(c=1;c<=n-1;c++){
scanf("%d", &l2);
if(l2-r1>t1) a=t1;
else a=(l2-r1);
if(l2-r1-t1>t2) b=t2;
else if(l2-r1>t1) b=(l2-(r1+t1));
else b=0;
total=total+p1*(r1-l1)+p1*a+p2*b+p3*(l2-(r1+a+b));
scanf("%d", &r2);
l1=l2;
r1=r2;
}
}
printf("%ld", total+p1*(r1-l1));
return 0;
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | a45819e2cfffb6bb3b43320fcb84fe1e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
#include<stdlib.h>
struct interval{
int start;
int end;
}*period;
int main(void){
int n,normal,saver,sleep,t1,t2,i,j,total=0,between;
scanf("%d %d %d %d %d %d",&n,&normal,&saver,&sleep,&t1,&t2);
period=(struct interval *)calloc(n,sizeof(struct interval));
for(i=0;i<n;i++) scanf("%d %d",&period[i].start,&period[i].end);
for(i=0;i<n;i++){
total+=normal*(period[i].end-period[i].start);
if(i!=n-1){
between=period[i+1].start-period[i].end;
if(between>=t1){
between-=t1;
total+=t1*normal;
if(between>=t2){
between-=t2;
total+=t2*saver;
if(between>0){
total+=sleep*between;
}
}else{
total+=saver*between;
}
}else{
total+=normal*between;
}
}
}
printf("%d\n",total);
free(period);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 943f4620bc186c4738cfcdf883502b24 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main(int argc, char *argv[])
{
int p1, p2, p3, t1, t2, n, lr, l, r, e = 0;
scanf("%d %d %d %d %d %d", &n, &p1, &p2, &p3, &t1, &t2);
scanf("%d %d", &l, &r);
e += (r - l) * p1;
lr = r;
while(-- n)
{
scanf("%d %d", &l, &r);
e += (r - l) * p1;
if(l - lr <= t1)
e += (l - lr) * p1;
else
{
e += t1 * p1;
if(l - lr <= t1 + t2)
e += (l - lr - t1) * p2;
else
e += t2 * p2 + (l - lr - t1 - t2) * p3;
}
lr = r;
}
printf("%d\n", e);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | f65d24c200843e2c7513a6a373c3d9fb | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n,p1,p2,p3,t1,t2,sum=0,i,j,k,a,b,c,test;
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
scanf("%d %d",&i,&j);
sum=sum+((j-i)*p1);
for(test=1;test<n;test++){
scanf("%d %d",&a,&b);
sum=sum+((b-a)*p1);
k=a-j;
if(k>t1){
sum=sum+(t1*p1);
k=k-t1;
}
else{
sum=sum+(k*p1);
k=0;
}
if(k>t2){
sum=sum+(p2*t2);
k=k-t2;
}
else{
sum=sum+(k*p2);
k=0;
}
sum=sum+(k*p3);
i=a;
j=b;
}
printf("%d\n",sum);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | a5ec524ea77b4493a3c5fe7ef10387c4 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <stdlib.h>
int main() {
int p1, p2, p3, t1, t2, n;
scanf("%d%d%d%d%d%d", &n, &p1, &p2, &p3, &t1, &t2);
{
int i;
int sum = 0;
int rp = -1;
for (i = 0; i < n; ++i) {
int l, r;
scanf("%d%d", &l, &r);
sum += (r - l) * p1;
if (rp != -1) {
if (l - rp <= t1)
sum += (l - rp) * p1;
else if (l - rp <= t1 + t2)
sum += t1 * p1 + (l - rp - t1) * p2;
else
sum += t1 * p1 + t2 * p2 + (l - rp - t1 - t2) * p3;
}
rp = r;
}
printf("%d", sum);
}
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 772efcc9204125a263ed69b227f86f68 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main ()
{
int n, p1, p2, p3, t1, t2;
scanf ("%d %d %d %d %d %d", &n, &p1, &p2, &p3, &t1, &t2);
int l[100], r[100];
for (int i = 0; i < n; i++)
scanf ("%d %d", &l[i], &r[i]);
int total_power = (r[0] - l[0]) * p1;
for (int i = 1; i < n; i++)
{
int gap, normal, saver, sleep;
gap = l[i] - r[i-1];
normal = gap < t1 ? gap : t1;
gap -= normal;
saver = gap < t2 ? gap : t2;
gap -= saver;
sleep = gap;
total_power += normal * p1 + saver * p2 + sleep * p3;
total_power += (r[i] - l[i]) * p1;
}
printf ("%d\n", total_power);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 22d8d5e1a7ac88df88fcb6898cde2d01 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n,p1,p2,p3,t1,t2,i,a,b,x,consume=0;
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
for(i=1;i<=n;i++){
scanf("%d %d",&a,&b);
if(i>1){
if(a-x>=t1){
consume+=t1*p1;
if(a-x-t1>=t2)
consume+=(t2*p2)+(a-x-t1-t2)*p3;
else
consume+=(a-x-t1)*p2;
}
else
consume+=(a-x)*p1;}
consume+=(b-a)*p1;
x=b;
}
printf("%d\n",consume);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | f5f77c92aefe4ed428665acfbb4509de | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
long int sumP = 0;
long int n, PN, PSS,PS, TSS, TS, delT, li, ri, lip1, rip1, i;
scanf("%ld %ld %ld %ld %ld %ld", &n, &PN, &PSS, &PS, &TSS, &TS);
scanf("%ld %ld", &li, &ri);
sumP += (ri-li)*PN;
for(i = 1; i < n; i++){
scanf("%ld %ld", &lip1, &rip1);
sumP += (rip1-lip1)*PN;
delT = lip1-ri;
if(delT<=TSS)
sumP += delT*PN;
else{
sumP += TSS*PN;
if(delT <= TSS+TS)
sumP += (delT-TSS)*PSS;
else{
sumP += TS*PSS+(delT-TSS-TS)*PS;
}
}
ri = rip1; li = lip1;
}
printf("%ld", sumP);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | a4c63bb8bf01bd2fef645fabc8f8fa5a | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int ans=0,i,j,k,n,p1,p2,p3,t1,t2;
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
int a[n],b[n];
for(i=0;i<n;i++)
scanf("%d %d",&a[i],&b[i]);
for(i=0;i<n;i++)
{
j=b[i]-a[i];
ans=ans+j*p1;
}
for(i=1;i<n;i++)
{
k=a[i]-b[i-1];
if(k<=t1)
ans=ans+k*p1;
else if(k<=(t1+t2))
ans=ans+t1*p1+(k-t1)*p2;
else
ans=ans+t1*p1+t2*p2+p3*(k-t1-t2);
}
printf("%d",ans);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 77ce0ccd2d4f4a0a9006e1e72473076f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int w[1500];
int main()
{
int n, p1, p2, p3, t1, t2, x, l, r, e, L, R, i, j;
scanf("%d%d%d%d%d%d", &n, &p1, &p2, &p3, &t1, &t2);
for (i = 0; i < n; i++)
{
scanf("%d%d", &l, &r);
l++;
if (i == 0)
L = l;
if (i == n-1)
R = r;
for (x = l; x <= r; x++)
w[x] = p1;
if (i != 0)
{
x = 0;
for (j = e+1; j < l; j++)
{
if (x < t1)
w[j] = p1;
else
if (x < t1+t2)
w[j] = p2;
else
w[j] = p3;
x++;
}
}
e = r;
}
int ans = 0;
for (i = L; i <= R; i++)
ans += w[i];
printf("%d\n", ans);
return 0;
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 16db86dd4f4753d1f68c2400d0d53923 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int i,n,p1,p2,p3,t1,t2;
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
int sum=0,arr[n][2];
for(i=0;i<n;i++)
{
scanf("%d %d",&arr[i][1],&arr[i][2]);
}
for(i=0;i<n;i++)
{
sum=(sum+(arr[i][2]-arr[i][1])*p1);
if(n>(i+1))
{
if((arr[i+1][1]-arr[i][2])>=t1)
{
sum=sum+(t1*p1);
if(arr[i+1][1]-arr[i][2]-t1>=t2)
{
sum=sum+(t2*p2)+(arr[i+1][1]-arr[i][2]-t1-t2)*p3;
}
else
sum=sum+(arr[i+1][1]-arr[i][2]-t1)*p2;
}
else
sum=sum+(arr[i+1][1]-arr[i][2])*p1;
}
}
printf("%d",sum);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 5ef1e2efd6b021c262c256650726f5df | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n,p1,p2,p3,t1,t2;
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
int sum=0,i,a,b,k;
for(i=0;i<n;i++)
{scanf("%d%d",&a,&b);
if(i==0)
{sum=(b-a)*p1;
k=b;}
else
{if(a-k<=t1)
sum=sum+p1*(a-k)+(b-a)*p1;
else if(a-k>t1 && a-k<=t1+t2)
sum=sum+p1*t1+p2*(a-k-t1)+(b-a)*p1;
else
sum=sum+p1*t1+p2*t2+p3*(a-k-t1-t2)+p1*(b-a);
k=b;
}
}
printf("%d\n",sum);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 2529c80a7889f83e8e8c7b0c13d30993 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] |
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
long long int i,n,p1,p2,p3,interval,normal,save,super_save,previous,sum=0;
long long int x,y,t1,t2,tem;
scanf("%lld %lld %lld %lld %lld %lld",&n,&p1,&p2,&p3,&t1,&t2);
for(i=0;i<n;i++)
{
scanf("%lld %lld",&x,&y);
if(i==0)
previous=x; //for first time only
interval=x-previous; //as no touch between this moment.
//normal=touching moment+t1 time to go save mood or left time if interval is less then the period
tem=(interval>t1)?t1:interval;
normal=(y-x)+tem;
interval-=tem;
//save=t2-t1 time to go super_save mood or left time if left interval is less then the period
save=(interval>t2)?t2:interval;
interval-=save;
//super_save=left time of interval,,
super_save=interval;
//interval=0;
///so the three distinct time is detected now time multiply with their fixed time and save the value
sum=sum+normal*p1+save*p2+super_save*p3;
previous=y;
}
printf("%lld\n",sum);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 8873a69350c22cca7cc5a1883dbfa7e5 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main(void) {
int n, i;
int P1, P2, P3, T1, T2;
scanf("%d%d%d%d%d%d", &n, &P1, &P2, &P3, &T1, &T2 );
int prev = 0, ans = 0;
for (i = 0; i < n; i ++) {
int l, r, R;
scanf("%d%d", &l, &r);
ans += P1*(r-l);
if (prev != 0) {
R = l - prev;
if (R <= T1)
ans += P1*R;
else if (R > T1 && R-T1 <= T2)
ans += P1*T1 + P2*(R-T1);
else
ans += P1*T1 + P2*T2 + P3*(R-T1-T2);
}
prev = r;
}
printf("%d\n", ans);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 50e88bae4bff63daceb01019fb861e00 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n,p1,p2,p3,t1,t2;
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
int i,range[2*n];
for(i=0;i<n*2;i++)
{
scanf("%d",&range[i]);
}
int total1=0,total2=0,total3=0;
for(i=0;i<2*n;i+=2)
{
total1+=range[i+1]-range[i];
}
int time;
for(i=1;i<2*n-1;i+=2)
{
time = range[i+1]-range[i];
if((range[i+1]-range[i])<=t1)
{
total1+=range[i+1]-range[i];
time=0;
}
else
{
total1+=t1;
time-=t1;
}
if(time!=0)
{
if(time<=t2)
{
total2+=time;
time=0;
}
else
{
total2+=t2;
time-=t2;
}
}
if (time!=0)
{
total3+=time;
}
}
int Ptotal=0;
Ptotal= total1*p1 + total2*p2 + total3*p3;
printf("%d\n",Ptotal);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 0ee5f644935dda5380c24c9e7736d873 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main(){
int i,j,k,l,m,n;
int T1,T2,P1,P2,P3;
int a[120], b[120], res=0;
scanf("%d%d%d%d%d%d",&n,&P1,&P2,&P3,&T1,&T2);
rep(i,n) scanf("%d%d",a+i,b+i);
rep(i,n){
res += (b[i]-a[i])*P1;
if(i){
k=a[i]-b[i-1];
m=k; if(m>T1) m=T1;
k-=m; res += P1*m;
m=k; if(m>T2) m=T2;
k-=m; res += P2*m;
res += P3*k;
}
}
printf("%d\n",res);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 732a68768f11efffbc801e21e3017b85 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n, p1, p2, p3, t1, t2, sum = 0, i, a, b, c;
scanf("%d %d %d %d %d %d", &n, &p1, &p2, &p3, &t1, &t2);
scanf("%d %d", &a, &b);
sum += p1*(b - a);
c = b;
for(i = 1; i < n; i++)
{
scanf("%d %d", &a, &b);
sum += p1 * (b - a);
if(t1 >= (a - c))
sum += p1 * (a - c);
else if(a - c > t1 && a - c <= (t1+t2))
sum += p1 * t1 + p2 * (a - c - t1);
else
sum += p1 * t1 + p2 * t2 + p3 * ((a - c) - (t1 + t2));
c = b;
}
printf("%d", sum);
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | a0f4571bcbca7c160de29bae6e231c19 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#define max(a, b) ((a > b) ? a : b)
#define min(a, b) ((a < b) ? a : b)
int main() {
int n, p1, p2, p3, t1, t2;
scanf("%d %d %d %d %d %d", &n, &p1, &p2, &p3, &t1, &t2);
int t = 0, power = 0;
int i;
for(i = 0; i < n; i++) {
int l, r;
scanf("%d %d", &l, &r); if(i == 0) { t = l; } // count l1 -> rn
int pt1 = min(l - t, t1); power += (p1 * pt1); t += pt1;
int pt2 = min(l - t, t2); power += (p2 * pt2); t += pt2;
power += (p3 * (l - t)); t = l;
power += (p1 * (r - t)); t = r;
}
printf("%d\n", power);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | bfe67e702fae28749b8031dc1105c6a7 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
struct interval
{
int l;
int r;
};
main()
{
int n,p1,p2,p3,t1,t2,i,j,power;
struct interval time[105];
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
for(i=0;i<n;i++)
scanf("%d %d",&time[i].l,&time[i].r);
power=(time[0].r-time[0].l)*p1;
for(i=1;i<n;i++)
{
power+=(time[i].r-time[i].l)*p1;
j=time[i].l-time[i-1].r;
if(j>=t1)
power+=p1*t1;
else
power+=p1*j;
j-=t1;
if(j>=t2)
power+=p2*t2;
else if(j>0)
power+=p2*j;
j-=t2;
if(j>0)
power+=p3*j;
}
printf("%d\n",power);
return 0;
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 3738f37d2b7ad76b3e49a5b7229a9760 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main(void)
{
int n , p1, p2, p3, t1, t2;
int i, j, l0, r0, l = 0, r = 0, sum = 0;
scanf("%d%d%d%d%d%d", &n, &p1, &p2, &p3, &t1, &t2);
scanf("%d%d", &l0, &r0);
for (i = 1; i < n; i ++)
{
sum += (r0-l0)*p1;
scanf("%d%d", &l, &r);
if (l-r0 >= t1+t2)
{
sum += p1*t1+p2*t2+p3*(l-r0-t1-t2);
}else if (l-r0 >= t1)
{
sum += p1*t1+p2*(l-r0-t1);
}else
{
sum += p1*(l-r0);
}
l0 = l, r0 = r;
}
sum += (r0-l0)*p1;
printf("%d\n", sum);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | f448c40ab90b89b2ebf87027e23f9097 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <math.h>
int main(){
int n,P1,P2,P3,T1,T2,d=0,s,i,j;
scanf("%d%d%d%d%d%d",&n,&P1,&P2,&P3,&T1,&T2);
int arr[n][2];
for(i=0;i<n;i++){
for(j=0;j<2;j++){
scanf("%d",&arr[i][j]);
}}
for(i=0;i<n;i++){
d=d+(arr[i][1]-arr[i][0])*P1;
}
for(i=0;i<n-1;i++){
s=arr[i+1][0]-arr[i][1];
if(s<=T1)
d=d+(s*P1);
else if(s>T1){
d=d+(P1*T1);
s=s-T1;
if(s<=T2)
d=d+(s*P2);
else {
d=d+(T2*P2);
s=s-T2;
d=d+(s*P3);
}}}
printf("%d",d);
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 00285579847c890787fecf38c0219ca2 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n,p1,p2,p3,t1,t2,i,j,k;
long long ans=0;
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
int A[n][2];
for(i=0;i<n;i++)
{
scanf("%d%d",&A[i][0],&A[i][1]);
ans+=(A[i][1]-A[i][0])*p1;
if(i>0)
{
j=A[i][0]-A[i-1][1];
if(j>=t1)
{
ans+=(t1*p1);
j=j-t1;
if(j>=t2)
{
ans+=(t2*p2);
ans+=((j-t2)*p3);
}
else
ans+=(j*p2);
}
else
ans+=(j*p1);
}
}
printf("%I64d",ans);
return 0;
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | d54a00ca01e49b427243772ec74fc99e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n,p1,p2,p3,t1,t2,l[101],r[101],x;
int power=0,i;
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
for(i=0;i<n;i++)
scanf("%d%d",&l[i],&r[i]);
for(i=0;i<n-1;i++)
{power+=((r[i]-l[i])*p1);
x=l[i+1]-r[i];
if(x<=t1)
power+=(x*p1);
else if(x<=t1+t2)
{power+=(t1*p1);
power+=((x-t1)*p2);
}
else
{power+=(t1*p1);
power+=(t2*p2);
power+=((x-t1-t2)*p3);
}
}
power+=((r[i]-l[i])*p1);
printf("%d",power);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 58ffe1f04f6eea146fb285c213738304 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n,p1,p2,p3,t1,t2,c=0;
int i,j,m,r,l,t,sum=0;
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
int arr[n][2];
r=t1+t2;
for ( i=0 ; i<n ; i++)
{
scanf("%d%d",&arr[i][0],&arr[i][1]);
}
for ( i=0 ; i<n ; i++)
{
m = arr[i][1]-arr[i][0];
c++;
t = m*p1;
sum += t;
if ( n>1 && c<=n-1 )
{
l = arr[i+1][0]-arr[i][1];
if ( l>r)
{
t = (p1*t1)+(p2*t2)+((l-r)*p3);
sum +=t;
}
else if (l==r)
{
t = (p1*t1)+(p2*t2);
sum +=t;
}
else
{
if (l<t1 || l==t1)
{
t = p1*l;
sum +=t;
}
else
{
t = (p1*t1)+(l-t1)*p2;
sum +=t;
}
}
}
}
printf("%d\n",sum);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 65b93354d9cc465646e234dacd08a91e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main(){
int n, p1, p2, p3, t1, t2;
scanf("%d%d%d%d%d%d", &n, &p1, &p2, &p3, &t1, &t2);
int i, a, b, ans = 0, last;
scanf("%d%d", &a, &b);
ans += (b-a) * p1;
last = b;
for(i = 1; i < n; ++i){
scanf("%d%d", &a, &b);
if(a-last >= t1+t2){
ans += t1 * p1;
ans += t2 * p2;
ans += (a-last-t1-t2) * p3;
}else if(a-last >= t1){
ans += t1 * p1;
ans += (a-last-t1) * p2;
}else{
ans += (a-last) * p1;
}
ans += (b-a) * p1;
last = b;
}
printf("%d\n", ans);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 2bc6f1fce12f194a1697405a65491def | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,p1,p2,p3,t1,t2,p=0;
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
int a[n][2],i;
for(i=0;i<=n-1;i++)
{
scanf("%d %d", &a[i][0] , &a[i][1]);
}
for(i=0;i<=n-1;i++)
{
p+=(a[i][1]-a[i][0])*p1;
if(i<=n-2&&a[i+1][0]-a[i][1]>t1)
{
p+=t1*p1;
if(a[i+1][0]-a[i][1]>t1+t2)
{
p+=p2*t2+(a[i+1][0]-a[i][1]-t1-t2)*p3;
}
else
{
p+=p2*(a[i+1][0]-a[i][1]-t1);
}
}
else if(i<=n-2)
{
p+=p1*(a[i+1][0]-a[i][1]);
}
}
printf("%d",p);
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 98ced2c3e5051678e4e14645a673ba5c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
struct aa
{
int start;
int end;
}time[101];
int main()
{
int n,p1,p2,p3,t1,t2;
while(scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2)!=-1)
{
for(int i=0;i<n;i++)
scanf("%d%d",&time[i].start,&time[i].end);
int p,sum;
sum=0;
p=-1;
for(int i=0;i<n;i++)
{
if(p!=-1)
{
int dt=time[i].start-p;
if(dt>t1+t2)
sum+=t1*p1+t2*p2+p3*(dt-t1-t2);
else if(dt>t1)
sum+=t1*p1+p2*(dt-t1);
else
sum+=dt*p1;
}
sum+=(time[i].end-time[i].start)*p1;
p=time[i].end;
}
printf("%d\n",sum);
}
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 0e585365083febd87bc087d0b696f113 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
main()
{
//freopen( "input.dat", "r", stdin );
int i, o, p, j, k, l, n, m;
int p1, p2, p3, t1, t2;
int x, y, yy;
int output = 0;
scanf( "%d %d %d %d %d %d", &n, &p1, &p2, &p3, &t1, &t2 );
scanf( "%d %d", &x, &y );
output += (y-x) * p1;
for (i=2;i<=n;++i)
{
yy = y;
scanf( "%d %d", &x, &y );
p = x - yy;
output += (y-x) * p1;
if (p <= t1)
{
output += p * p1;
}
else
{
if (p<= t1 + t2)
{
output += p1 * t1 + (p-t1) * p2;
}
else
{
output += p1 * t1 + p2 * t2 + (p-t1-t2) * p3;
}
}
}
printf( "%d\n", output );
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | bd29a4ef85880dc051616d8e1fb91237 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int n,p1,p2,p3,t1,t2,a,b,i,lr=0,power=0;
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
scanf("%d %d",&a,&b);
power+=(b-a)*p1;
lr=b;
for(i=1;i<n;i++)
{
scanf("%d %d",&a,&b);
power+=(b-a)*p1;
if(lr+t1<=a)
{
power+=(t1*p1);
if(lr+t1+t2<=a)
power+=(t2*p2)+(a-lr-t1-t2)*p3;
else
power+=(a-lr-t1)*p2;
}
else
power+=(a-lr)*p1;
lr=b;
}
printf("%d",power);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | a0da1280853fda706175031cbadffed9 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n=0,p1=0,p2=0,p3=0,t1=0,t2=0,li=0,ri=0,l1=0,r1=0;
int k=1,diff ;
scanf("%d",&n);
scanf("%d",&p1);
scanf("%d",&p2);
scanf("%d",&p3);
scanf("%d",&t1);
scanf("%d",&t2);
int a=0,b=0,s;
scanf("%d",&l1);
scanf("%d",&r1);
s=(r1-l1)*p1;
while(k<n)
{
scanf("%d",&li);
scanf("%d",&ri);
s+=(ri-li)*p1;
diff=li-r1;
if (t1>=diff)
{
s+=diff*p1;
}
else
{
if(t2>=(diff-t1))
{
s+=(diff-t1)*p2+t1*p1;
}
else
{
s+=t1*p1+t2*p2+p3*(diff-t1-t2);
}
}
l1=li;
r1=ri;
k++;
}
printf("%d",s);
return 0 ;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 44a65a55ffdbacf2c764ce257ef0334e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main()
{
int n,a,b,c,d,e,i,j,s,w,f;
scanf("%d %d %d %d %d %d",&n,&a,&b,&c,&d,&e);
int ara[1000][1000];
for (i=0;i<n;i++){
for (j=0;j<2;j++){
scanf("%d",&ara[i][j]);
}
}
s=0;
for (i=0;i<n;i++){
s=s+(ara[i][1]-ara[i][0])*a;
}
f=0;
for (i=0;i<n-1;i++){
if ((d+e)<=(ara[i+1][0]-ara[i][1])){
f=f+a*d+b*e+(ara[i+1][0]-ara[i][1]-d-e)*c;
}
else{
if (d>=(ara[i+1][0]-ara[i][1])){
f=f+(ara[i+1][0]-ara[i][1])*a;
}
else{
f=f+a*d+(ara[i+1][0]-ara[i][1]-d)*b;
}
}
}
printf("%d",s+f);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | b91d38fa96362c48b5fa7f2f78d25e38 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <stdlib.h>
struct period{int start;
int end;};
struct period shift[1000];
int calcu(int n,int p1,int p2,int p3,int t1,int t2);
int main()
{
int n,p1,p2,p3,t1,t2;
int counter;
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
for(counter=0;counter<n;counter++)
{
scanf("%d %d",&shift[counter].start,&shift[counter].end);
}
printf("%d",calcu(n,p1,p2,p3,t1,t2));
return 0;
}
int calcu(int n,int p1,int p2,int p3,int t1,int t2)
{
int bet=0;
int bet2=0;
int total=0;
int counter;
for(counter=0;counter<n;counter++)
{
if(counter==n-1)
total=total+((shift[counter].end-shift[counter].start)*p1);
else
{
total=total+((shift[counter].end-shift[counter].start)*p1);
bet=shift[counter+1].start-shift[counter].end;
bet=bet-t1;
if(bet>0)
{
bet2=bet-t2;
if(bet2>0)
{
total=total+bet2*p3;
total=total+t2*p2;
total=total+t1*p1;
}
else
{
total=total+bet*p2;
total=total+t1*p1;
}
}
else
{
bet=shift[counter+1].start-shift[counter].end;
total=total+bet*p1;
}
}
}
return total;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 0d46a0272d4aeb8922bb9dd6bafcf279 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int i,j,k,l,m,n,t=0,a[200],b,c;
scanf("%d%d%d%d%d%d",&n,&i,&j,&k,&l,&m);
for(b=0;b<(2*n);b+=2)
{
scanf("%d%d",&a[b],&a[b+1]);
t+=(a[b+1]-a[b])*i;}
for(b=2;b<(2*n);b+=2)
{
c=a[b]-a[b-1];
if(c>m+l)
{
t+=i*l;
t+=j*m;
t+=k*(c-l-m);
}
else
if(c>l)
{
t+=i*l;
t+=j*(c-l);
}
else
t+=i*c;
}
printf("%d",t);
return(0);
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 8a411189a1ca6e09a3a9030f1ddf43e7 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n;
int w[100],p1,p2,p3,t1,t2;
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
int i,time,power=0,power1=0;;
int l[1440],r[1440];
scanf("%d %d",&l[0],&r[0]);
power+=((r[0]-l[0])*p1);
for(i=1;i<n;i++)
{
scanf("%d %d",&l[i],&r[i]);
power+=((r[i]-l[i])*p1);
time=l[i]-r[i-1];
if(time/t1)
{
power+=(t1*p1);
time=time-t1;
if(time/t2)
{
power+=(t2*p2);
time-=t2;
power+=(time*p3);
}
else
{
//time-=t2;
power+=(time*p2);
}
}
else
{
//time-=t1;
power+=(time*p1);
}
}
printf("%d",power);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | f6485ca92e4f2ff1abbf3c158d7178aa | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main(){
int n, p1, p2, p3, t1, t2, prev = 0, l, r, res = 0;
scanf("%d%d%d%d%d%d", &n, &p1, &p2, &p3, &t1, &t2);
while(n--){
scanf("%d%d", &l, &r);
if(!prev){
prev = l;
}
res += (r-l)*p1;
if(l-prev <= t1){
res += (l-prev)*p1;
}
else if(l-prev <= t1+t2){
res += t1*p1 + (l-prev-t1)*p2;
}
else{
res += t1*p1 + t2*p2 + (l-prev-t1-t2)*p3;
}
prev = r;
}
printf("%d\n", res);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | a228020a40af58a4a7f9283481c4f5ab | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int a[128][2];
int n;
int main() {
int ret=0,i,j,p1,p2,p3,t1,t2;
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
for(i=0;i<n;i++) scanf("%d %d",&a[i][0],&a[i][1]);
for(i=a[0][0],j=0;i<a[n-1][1];i++) {
if (i<a[j][1]) ret+=p1;
else if (i>=a[j+1][0]) j++, ret+=p1;
else if (i-a[j][1]>=t1+t2) ret+=p3;
else if (i-a[j][1]>=t1) ret+=p2;
else ret+=p1;
}
printf("%d\n",ret);
return 0;
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 557f5fe333be214d1705b5b236528baf | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
int main()
{
int n,p1,p2,p3,t1,t2,st,end,i,end_last,ans,time;
ans=0;
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
for(i=0;i<n;i++)
{
if(i==0)
{
scanf("%d%d",&st,&end);
ans+=(end-st)*p1;
end_last=end;
}
else
{
scanf("%d%d",&st,&end);
ans+=(end-st)*p1;
time=st-end_last;
while(time>0)
{
if(time>=t1)
{
ans+=t1*p1;
time-=t1;
}
else
{
ans+=time*p1;
time=0;
}
if(time==0)
break;
if(time>=t2)
{
ans+=t2*p2;
time-=t2;
}
else
{
ans+=time*p2;
time=0;
}
if(time==0)
break;
ans+=time*p3;
time=0;
}
end_last=end;
}
}
printf("%d\n",ans);
return(0);
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 3017a2e68feae763382fb0e08765ea15 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
#include<string.h>
int main()
{
int i,j,k,l,m,n,m1,m2,ans=0,t;
int p1,p2,p3,t1,t2,n1;
scanf("%d %d %d %d %d %d",&t,&p1,&p2,&p3,&t1,&t2);
scanf("%d %d",&m,&n);
ans+=(n-m)*p1;
m1=m;n1=n;
for(i=1;i<t;i++)
{
scanf("%d %d",&m,&n);
ans+=(n-m)*p1;
ans+=min(m-n1,t1)*p1;
ans+=min(m-n1-t1,t2)*p2;
if(m-n1-t1-t2>0)
ans+=(m-n1-t1-t2)*p3;
n1=n;
m1=m;
}
printf("%d",ans);
return 0;
}
int min(int a,int b)
{
int ans;
if(a<b)
ans=a;
else
ans=b;
if(ans<0)
return 0;
else
return ans;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | dc8f91eeab2a2a66259b5d55b17769b2 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
int n, P1, P2, P3, T1, T2;
int a[200][2];
int i,j,k,l;
int tmp,tmp1,tmp2,tmp3,next,sum;
scanf("%d%d%d%d%d%d",&n,&P1,&P2,&P3,&T1,&T2);
for(i=0;i<n;i++)
scanf("%d%d",&a[i][0],&a[i][1]);
sum=0;tmp1=0;tmp2=0;tmp3=0;next=0;tmp=0;
for(i=0;i<n;i++){
sum=sum+(a[i][1]-a[i][0])*P1;
if(i+1<n)
next=a[i+1][0]-a[i][1];
else
next=0;
if(next>0){
//printf("%d\n",next);
if(next>=T1){
tmp1=T1; tmp+=P1*tmp1;
next=next-T1;
}
else if(next<T1){
tmp1=next;tmp+=P1*tmp1;
next=0;goto Down;
}
//printf("%d\n",next);
if(next>=T2){
tmp2=T2;tmp+=P2*tmp2;
next=next-T2;
}
else if(next<T2){
tmp2=next;tmp+=P2*tmp2;
next=0;goto Down;
}
//printf("%d\n",next);
if(next>0){
tmp3=next;tmp+=P3*tmp3;
next=0;
}
else{
next=0;goto Down;
}
}
Down:
next=0;
//printf("%d",tmp);
}
printf("%d\n",sum+tmp);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | beffd27ebc80bc899862bf51b6c0e1f8 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main ()
{
int N, P1, P2, P3, T1, T2;
scanf("%d %d %d %d %d %d",&N,&P1,&P2,&P3,&T1,&T2);
int x1, y1, x2, y2;
scanf("%d %d",&x1,&y1);
int res = (y1 - x1) * P1;
int i;
for (i = 1; i < N; i++)
{
scanf("%d %d",&x2,&y2);
int t = x2 - y1;
if (t <= T1)
{
res += (t * P1);
}
else if (t <= (T1 + T2))
{
res += (T1 * P1 + (t - T1) * P2);
}
else
{
res += (T1 * P1 + T2 * P2 + (t - T1 - T2) * P3);
}
res += (y2 - x2) * P1;
x1 = x2;
y1 = y2;
}
printf("%d\n",res);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | ad86d6954ceeb7af88d8d0ccb3957986 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int n,p1,p2,p3,t1,t2,a,c,b,e,i,d=0;
long int p=0;
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
scanf("%d %d",&a,&b);
if(n==1) p=(b-a)*p1;
else { p=(b-a)*p1;
for(i=1;i<n;i++){
scanf("%d %d",&c,&e);
d=c-b;
if(d>=t1) {p+=t1*p1;
d-=t1;
}
else if(d>0) {p+=d*p1;
d=0;
}
if(d>=t2) {p+=t2*p2;
d-=t2;
}
else if(d>0) {p+=d*p2;
d=0;
}
if(d>0) p+=d*p3;
p+=p1*(e-c);
a=c;
b=e;
}
}
printf("%ld",p);
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 8f9e2d28b2088572655fbd17d254db4f | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main()
{
int n, P1, P2, P3, T1, T2;
scanf("%d%d%d%d%d%d", &n, &P1, &P2, &P3, &T1, &T2);
int i,a[210];
int sum = 0;
for (i = 0; i <= n - 1; i++)
{
scanf("%d %d", &a[i * 2], &a[i * 2 + 1]);
sum += (a[i * 2 + 1] - a[i * 2])*P1;
}
for (i = 1; i <= n-1; i++)
{
int d = a[i * 2] - a[i * 2 - 1];
if (d > T1 + T2)
{
sum += (d - (T1 + T2))*P3;
d = T1 +T2;
}
if (d > T1 && d <= T1+T2)
{
sum += (d - T1 )*P2;
d = T1;
}
if (d <= T1)
{
sum += d*P1;
}
}
printf("%d\n", sum);
return 0;
} | |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 258236c9d6188175471cb216dde3dc75 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | #include <stdio.h>
int main( void )
{
int n, p1, p2, p3, t1, t2, t3;
int i;
int start, end, total, prev;
scanf( "%d %d %d %d %d %d", &n, &p1, &p2, &p3, &t1, &t2 );
t3= t1 + t2;
scanf( "%d %d", &start, &end );
prev = end;
total = 0;
total += ( end - start ) * p1;
for ( i = 1; i < n; i++ ) {
int left;
scanf( "%d %d", &start, &end );
total += ( end - start ) * p1;
left = ( start - prev ) ;
if ( left >= t1 ) {
total += p1 * t1;
left -= t1;
if ( left >= t2 ) {
total += p2 * t2;
left -= t2 ;
if ( left > 0 ) {
total += p3 * left;
}
} else {
total += p2 * ( left );
}
} else {
total += p1 * ( left );
}
prev = end;
}
printf( "%d\n", total );
return 0;
}
| |
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods [l1,βr1],β[l2,βr2],β...,β[ln,βrn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,βrn]. | Output the answer to the problem. | C | 7ed9265b56ef6244f95a7a663f7860dd | 5408662e5ab96545d63921fcc6ee432b | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"implementation"
] | 1271346300 | ["1 3 2 1 5 10\n0 10", "2 8 4 2 5 10\n20 30\n50 100"] | null | PASSED | 900 | standard input | 1 second | The first line contains 6 integer numbers n, P1, P2, P3, T1, T2 (1ββ€βnββ€β100,β0ββ€βP1,βP2,βP3ββ€β100,β1ββ€βT1,βT2ββ€β60). The following n lines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (0ββ€βliβ<βriββ€β1440, riβ<βliβ+β1 for iβ<βn), which stand for the start and the end of the i-th period of work. | ["30", "570"] | main(n,a){int b,c,d,e,l,r,t,x;scanf("%u%u%u%u%u%u",&n,&a,&b,&c,&d,&e);c-=b;b-=a;e+=d;t=1e4;x=0;while(n--){scanf("%u%u",&l,&r);x+=a*(r-l);l-=t;t=r;x+=a*(l>0)*l+b*(l>d)*(l-d)+c*(l>e)*(l-e);}return!printf("%u",x);} | |
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.You have an array a of length 2n and m queries on it. The i-th query is described by an integer qi. In order to perform the i-th query you must: split the array into 2nβ-βqi parts, where each part is a subarray consisting of 2qi numbers; the j-th subarray (1ββ€βjββ€β2nβ-βqi) should contain the elements a[(jβ-β1)Β·2qiβ+β1],βa[(jβ-β1)Β·2qiβ+β2],β...,βa[(jβ-β1)Β·2qiβ+β2qi]; reverse each of the subarrays; join them into a single array in the same order (this array becomes new array a); output the number of inversions in the new a. Given initial array a and all the queries. Answer all the queries. Please, note that the changes from some query is saved for further queries. | Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query. | C | ea7f8bd397f80ba7d3add6f9609dcc4a | 68bec609b8b098c5e8e86672c040f386 | GNU C | standard output | 512 megabytes | train_000.jsonl | [
"combinatorics",
"divide and conquer"
] | 1396798800 | ["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"] | NoteIf we reverse an array x[1],βx[2],β...,βx[n] it becomes new array y[1],βy[2],β...,βy[n], where y[i]β=βx[nβ-βiβ+β1] for each i.The number of inversions of an array x[1],βx[2],β...,βx[n] is the number of pairs of indices i,βj such that: iβ<βj and x[i]β>βx[j]. | PASSED | 2,100 | standard input | 4 seconds | The first line of input contains a single integer nΒ (0ββ€βnββ€β20). The second line of input contains 2n space-separated integers a[1],βa[2],β...,βa[2n]Β (1ββ€βa[i]ββ€β109), the initial array. The third line of input contains a single integer mΒ (1ββ€βmββ€β106). The fourth line of input contains m space-separated integers q1,βq2,β...,βqmΒ (0ββ€βqiββ€βn), the queries. Note: since the size of the input and output could be very large, don't use slow output techniques in your language. For example, do not use input and output streams (cin, cout) in C++. | ["0\n6\n6\n0", "0\n1\n0"] | #include <stdio.h>
#include <string.h>
#define N 20
#define ll __int64
ll a[(1 << N) + 1],aux[(1 << N) +1];
ll sum [N + 1][2];
ll LowerBound(ll a[],ll low, ll high ,ll value){
ll l, h,pos;
l = low;
h = high;
pos = low - 1;
while(l <= h) {
ll mid = (l + h) >> 1;
if (value > a[mid]) {
l = mid + 1;
pos = mid;
} else {
h = mid - 1;
}
}
return pos;
}
void Merge(ll a[],ll aux[],ll low, ll mid, ll high) {
ll i,j,k;
i = low,j = mid+1,k = low;
for (; k <= high; k++) {
if (j > high || i <= mid && aux[i] <= aux[j]) {
a[k] = aux[i];
i++;
} else {
a[k] = aux[j];
j++;
}
}
}
void Inversions(ll a[],ll aux[], ll low, ll high, ll deep) {
if (low >= high) {
return;
}
ll mid = (low + high) >> 1;
Inversions(aux,a,low, mid, deep-1);
Inversions(aux,a,mid+1, high, deep-1);
ll count = 0;
ll i = low,j = mid;
for (; i <= mid; i++) {
j = LowerBound(aux,j+1, high, aux[i]);
count += j - mid;
}
sum[deep][0] += count;
count = 0;
for (i= mid+1, j = low-1; i <= high; i++) {
j = LowerBound(aux,j+1, mid, aux[i]);
count += j - low + 1;
}
sum[deep][1] += count;
if (aux[mid] <= aux[mid+1]) {
memcpy(a+low,aux+low,sizeof(ll)*(high-low+1));
return;
}
Merge(a,aux,low, mid, high);
}
int main() {
ll n, m, que,i;
ll pow[30];pow[0] = 1;
for(i=1;i<30;i++)pow[i] = pow[i-1]*2;
while(~scanf("%I64d",&n)){
memset(sum,0,sizeof sum);
ll length = pow[n];
a[0] = length;
for (i= 1; i <= length; i++){
scanf("%I64d", &a[i]);
}
memcpy(aux,a,sizeof(ll)*(length+1));
Inversions(a,aux,1, a[0], n);
scanf("%I64d", &m);
while(m--) {
scanf("%I64d", &que);
ll ans = 0,temp;
while(que--){
temp = sum[que+1][0];
sum[que+1][0] = sum[que+1][1];
sum[que+1][1] = temp;
}
for (i = 0; i <= n; i++) {
ans += sum[i][0];
}
printf("%I64d\n",ans);
}
}
return 0;
} | |
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.You have an array a of length 2n and m queries on it. The i-th query is described by an integer qi. In order to perform the i-th query you must: split the array into 2nβ-βqi parts, where each part is a subarray consisting of 2qi numbers; the j-th subarray (1ββ€βjββ€β2nβ-βqi) should contain the elements a[(jβ-β1)Β·2qiβ+β1],βa[(jβ-β1)Β·2qiβ+β2],β...,βa[(jβ-β1)Β·2qiβ+β2qi]; reverse each of the subarrays; join them into a single array in the same order (this array becomes new array a); output the number of inversions in the new a. Given initial array a and all the queries. Answer all the queries. Please, note that the changes from some query is saved for further queries. | Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query. | C | ea7f8bd397f80ba7d3add6f9609dcc4a | a23acca927bec122b5cd902daa1b9c38 | GNU C | standard output | 512 megabytes | train_000.jsonl | [
"combinatorics",
"divide and conquer"
] | 1396798800 | ["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"] | NoteIf we reverse an array x[1],βx[2],β...,βx[n] it becomes new array y[1],βy[2],β...,βy[n], where y[i]β=βx[nβ-βiβ+β1] for each i.The number of inversions of an array x[1],βx[2],β...,βx[n] is the number of pairs of indices i,βj such that: iβ<βj and x[i]β>βx[j]. | PASSED | 2,100 | standard input | 4 seconds | The first line of input contains a single integer nΒ (0ββ€βnββ€β20). The second line of input contains 2n space-separated integers a[1],βa[2],β...,βa[2n]Β (1ββ€βa[i]ββ€β109), the initial array. The third line of input contains a single integer mΒ (1ββ€βmββ€β106). The fourth line of input contains m space-separated integers q1,βq2,β...,βqmΒ (0ββ€βqiββ€βn), the queries. Note: since the size of the input and output could be very large, don't use slow output techniques in your language. For example, do not use input and output streams (cin, cout) in C++. | ["0\n6\n6\n0", "0\n1\n0"] | #include <stdio.h>
int n,m,q,num[1100000];
int tmp[1100000];
long long v[25][3];
short flag[25];
long long work(int l,int r,int d)
{
int i,ll,rr,mid = (l+r)>>1;
long long a,b,c;
if(!d) return 0;
v[d][2] += (c=work(l,mid,d-1)+work(mid+1,r,d-1));
for(i=ll=l,rr=mid+1,b=0;i<=r;i++)
{
if(ll>mid || rr<=r && num[rr]<=num[ll]) tmp[i] = num[rr++];
else { tmp[i] = num[ll++]; b += r-rr+1;}
}
for(i=ll=l,rr=mid+1,a=0;i<=r;i++)
{
if(rr>r || ll<=mid && num[ll]<=num[rr]) tmp[i] = num[ll++];
else { tmp[i] = num[rr++]; a += mid-ll+1;}
}
for(i=l;i<=r;i++) num[i] = tmp[i];
v[d][0] += a; v[d][1] += b; v[d][2] += a;
return a+c;
}
int main()
{
int i,x;
long long a,b;
scanf("%d",&n); m = 1<<n;
for(i=1;i<=m;i++) scanf("%d",&num[i]);
work(1,m,n);
scanf("%d",&q);
while(q--)
{
scanf("%d",&x);
if(x)
{
for(i=1;i<=x;i++) v[i][2] = v[i-1][2]+v[i][flag[i]^=1];
for(;i<=n;i++) v[i][2] = v[i-1][2]+v[i][flag[i]];
}
printf("%I64d\n",v[n][2]);
}
return 0;
} | |
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.You have an array a of length 2n and m queries on it. The i-th query is described by an integer qi. In order to perform the i-th query you must: split the array into 2nβ-βqi parts, where each part is a subarray consisting of 2qi numbers; the j-th subarray (1ββ€βjββ€β2nβ-βqi) should contain the elements a[(jβ-β1)Β·2qiβ+β1],βa[(jβ-β1)Β·2qiβ+β2],β...,βa[(jβ-β1)Β·2qiβ+β2qi]; reverse each of the subarrays; join them into a single array in the same order (this array becomes new array a); output the number of inversions in the new a. Given initial array a and all the queries. Answer all the queries. Please, note that the changes from some query is saved for further queries. | Output m lines. In the i-th line print the answer (the number of inversions) for the i-th query. | C | ea7f8bd397f80ba7d3add6f9609dcc4a | 1b2ef44d927c0e9171b9c2125598a704 | GNU C | standard output | 512 megabytes | train_000.jsonl | [
"combinatorics",
"divide and conquer"
] | 1396798800 | ["2\n2 1 4 3\n4\n1 2 0 2", "1\n1 2\n3\n0 1 1"] | NoteIf we reverse an array x[1],βx[2],β...,βx[n] it becomes new array y[1],βy[2],β...,βy[n], where y[i]β=βx[nβ-βiβ+β1] for each i.The number of inversions of an array x[1],βx[2],β...,βx[n] is the number of pairs of indices i,βj such that: iβ<βj and x[i]β>βx[j]. | PASSED | 2,100 | standard input | 4 seconds | The first line of input contains a single integer nΒ (0ββ€βnββ€β20). The second line of input contains 2n space-separated integers a[1],βa[2],β...,βa[2n]Β (1ββ€βa[i]ββ€β109), the initial array. The third line of input contains a single integer mΒ (1ββ€βmββ€β106). The fourth line of input contains m space-separated integers q1,βq2,β...,βqmΒ (0ββ€βqiββ€βn), the queries. Note: since the size of the input and output could be very large, don't use slow output techniques in your language. For example, do not use input and output streams (cin, cout) in C++. | ["0\n6\n6\n0", "0\n1\n0"] | #include<stdio.h>
inline int get_ui();
int get_ui() {
char c;
for (; (c = getchar()) < '0' || c > '9';);
for (int a = c ^'0';; a = (a * 10) + (c ^ '0')) if ((c = getchar()) < '0' || c > '9') return a;
}
#define maxN 20
#define maxN2 1 << maxN
int data_fwd[maxN2], data_rev[maxN2], data_buf[maxN2], xlat[maxN + 1], n, n2;
long long acc_fwd[maxN + 1], acc_rev[maxN + 1], base_sum;
void helper(int *data, long long *acc) {
{
long long inv = 0;
for (int i = 0; i < n2; i += 2) {
int a = data[i];
if (a > data[i + 1]) {
data[i] = data[i + 1];
data[i + 1] = a;
inv++;
}
}
acc[0] = inv;
}
int width = 2;
int *bufhead = data_buf;
for (int level = 1; level < n; level++) {
long long inv = 0;
int *le = data, *ri = data + width, step = width * 2;
for (int *buf = bufhead; buf < bufhead + n2;) {
int i = 0, j = 0;
for (;;) {
if (le[i] > ri[j]) {
*buf++ = ri[j++];
if (j == width) {
inv += (long long) j * (width - i);
for (; i < width;) *buf++ = le[i++];
break;
};
} else {
inv += j;
*buf++ = le[i++];
if (i == width) {
for (; j < width;) *buf++ = ri[j++];
break;
}
}
}
le += step;
ri += step;
}
width <<= 1;
acc[level] = inv;
le = bufhead;
bufhead = data;
data = le;
}
}
int main() {
n = get_ui();
n2 = 1 << n;
for (int i = 0, j = n2 - 1; i < n2; i++, j--) data_fwd[i] = data_rev[j] = get_ui();
if (n) {
helper(data_fwd, acc_fwd);
helper(data_rev, acc_rev);
for (int i = 0; i < n; i++) {
if (acc_fwd[i] < acc_rev[i]) {
base_sum += acc_fwd[i];
acc_fwd[i] = acc_rev[i] - acc_fwd[i];
} else {
base_sum += acc_rev[i];
acc_fwd[i] -= acc_rev[i];
xlat[i] = 1;
}
}
}
for (int qwerycnt = get_ui(); qwerycnt > 0; qwerycnt--) {
for (int i = get_ui(); i > 0;) xlat[--i] ^= 1;
long long res = base_sum;
for (int i = 0; i < n; i++) if (xlat[i]) res += acc_fwd[i];
printf("%I64d\n", res);
}
return 0;
} | |
Recently an official statement of the world Olympic Committee said that the Olympic Winter Games 2030 will be held in Tomsk. The city officials decided to prepare for the Olympics thoroughly and to build all the necessary Olympic facilities as early as possible. First, a biathlon track will be built.To construct a biathlon track a plot of land was allocated, which is a rectangle divided into nβΓβm identical squares. Each of the squares has two coordinates: the number of the row (from 1 to n), where it is located, the number of the column (from 1 to m), where it is located. Also each of the squares is characterized by its height. During the sports the biathletes will have to move from one square to another. If a biathlete moves from a higher square to a lower one, he makes a descent. If a biathlete moves from a lower square to a higher one, he makes an ascent. If a biathlete moves between two squares with the same height, then he moves on flat ground.The biathlon track should be a border of some rectangular area of the allocated land on which biathletes will move in the clockwise direction. It is known that on one move on flat ground an average biathlete spends tp seconds, an ascent takes tu seconds, a descent takes td seconds. The Tomsk Administration wants to choose the route so that the average biathlete passes it in as close to t seconds as possible. In other words, the difference between time ts of passing the selected track and t should be minimum.For a better understanding you can look at the first sample of the input data. In this sample nβ=β6,βmβ=β7, and the administration wants the track covering time to be as close to tβ=β48 seconds as possible, also, tpβ=β3, tuβ=β6 and tdβ=β2. If we consider the rectangle shown on the image by arrows, the average biathlete can move along the boundary in a clockwise direction in exactly 48 seconds. The upper left corner of this track is located in the square with the row number 4, column number 3 and the lower right corner is at square with row number 6, column number 7. Among other things the administration wants all sides of the rectangle which boundaries will be the biathlon track to consist of no less than three squares and to be completely contained within the selected land.You are given the description of the given plot of land and all necessary time values. You are to write the program to find the most suitable rectangle for a biathlon track. If there are several such rectangles, you are allowed to print any of them. | In a single line of the output print four positive integers β the number of the row and the number of the column of the upper left corner and the number of the row and the number of the column of the lower right corner of the rectangle that is chosen for the track. | C | 667d00cac98b3bd07fc7c78be5373fb5 | 523927bdbd47ca3980295b9628a17663 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"constructive algorithms",
"data structures",
"binary search",
"brute force"
] | 1398409200 | ["6 7 48\n3 6 2\n5 4 8 3 3 7 9\n4 1 6 8 7 1 1\n1 6 4 6 4 8 6\n7 2 6 1 6 9 4\n1 9 8 6 3 9 2\n4 5 6 8 4 3 7"] | null | PASSED | 2,300 | standard input | 4.5 seconds | The first line of the input contains three integers n, m and t (3ββ€βn,βmββ€β300, 1ββ€βtββ€β109) β the sizes of the land plot and the desired distance covering time. The second line also contains three integers tp, tu and td (1ββ€βtp,βtu,βtdββ€β100) β the time the average biathlete needs to cover a flat piece of the track, an ascent and a descent respectively. Then n lines follow, each line contains m integers that set the heights of each square of the given plot of land. Each of the height values is a positive integer, not exceeding 106. | ["4 3 6 7"] | #include <stdio.h>
#include <stdlib.h>
#define INF 100000000000LL
#define lli long long int
int land[305][305];
lli hl[305][305];
lli vd[305][305];
lli hr[305][305];
lli vu[305][305];
int bi, bk, bj, bp;
lli delta;
void binary_search(int l, int r, int t, int i, int k, int j) {
int mid;
lli sum;
mid = (l + r) / 2;
while(l <= r) {
sum = vu[i][j] - vu[k][j] + hr[i][mid] - hr[i][j]
+ vd[k][mid] - vd[i][mid] + hl[k][j] - hl[k][mid];
if (llabs(t - sum) < delta) {
delta = llabs(t - sum);
bi = i;
bj = j;
bk = k;
bp = mid;
}
if (sum < t) {
l = mid + 1;
} else if (sum == t) {
break;
} else {
r = mid - 1;
}
mid = (l + r) / 2;
}
return;
}
int main(void) {
int n, m, t;
int tp, tu, td;
int i, j, k;
scanf(" %d %d %d", &n, &m, &t);
scanf(" %d %d %d", &tp, &tu, &td);
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
scanf(" %d", &land[i][j]);
}
}
for (i = 0; i < n; i++) {
hr[i][0] = 0;
for (j = 1; j < m; j++) {
hr[i][j] = hr[i][j - 1];
if (land[i][j] < land[i][j - 1]) {
hr[i][j] += td;
} else if (land[i][j] == land[i][j - 1]) {
hr[i][j] += tp;
} else {
hr[i][j] += tu;
}
}
hl[i][m - 1] = 0;
for (j = m - 2; j >= 0; j--) {
hl[i][j] = hl[i][j + 1];
if (land[i][j] < land[i][j + 1]) {
hl[i][j] += td;
} else if (land[i][j] == land[i][j + 1]) {
hl[i][j] += tp;
} else {
hl[i][j] += tu;
}
}
}
for (j = 0; j < m; j++) {
vd[0][j] = 0;
for (i = 1; i < n; i++) {
vd[i][j] = vd[i - 1][j];
if (land[i][j] < land[i - 1][j]) {
vd[i][j] += td;
} else if (land[i][j] == land[i - 1][j]) {
vd[i][j] += tp;
} else {
vd[i][j] += tu;
}
}
vu[n - 1][j] = 0;
for (i = n - 2; i >= 0; i--) {
vu[i][j] = vu[i + 1][j];
if (land[i][j] < land[i + 1][j]) {
vu[i][j] += td;
} else if (land[i][j] == land[i + 1][j]) {
vu[i][j] += tp;
} else {
vu[i][j] += tu;
}
}
}
bi = bj = bk = bp = 0;
delta = INF;
for (i = 0; i < n; i++) {
for (k = i + 2; k < n; k++) {
for (j = 0; j < m; j++) {
binary_search(j + 2, m - 1, t, i, k, j);
}
}
}
printf("%d %d %d %d\n", bi + 1, bj + 1, bk + 1, bp + 1);
return 0;
}
| |
Recently an official statement of the world Olympic Committee said that the Olympic Winter Games 2030 will be held in Tomsk. The city officials decided to prepare for the Olympics thoroughly and to build all the necessary Olympic facilities as early as possible. First, a biathlon track will be built.To construct a biathlon track a plot of land was allocated, which is a rectangle divided into nβΓβm identical squares. Each of the squares has two coordinates: the number of the row (from 1 to n), where it is located, the number of the column (from 1 to m), where it is located. Also each of the squares is characterized by its height. During the sports the biathletes will have to move from one square to another. If a biathlete moves from a higher square to a lower one, he makes a descent. If a biathlete moves from a lower square to a higher one, he makes an ascent. If a biathlete moves between two squares with the same height, then he moves on flat ground.The biathlon track should be a border of some rectangular area of the allocated land on which biathletes will move in the clockwise direction. It is known that on one move on flat ground an average biathlete spends tp seconds, an ascent takes tu seconds, a descent takes td seconds. The Tomsk Administration wants to choose the route so that the average biathlete passes it in as close to t seconds as possible. In other words, the difference between time ts of passing the selected track and t should be minimum.For a better understanding you can look at the first sample of the input data. In this sample nβ=β6,βmβ=β7, and the administration wants the track covering time to be as close to tβ=β48 seconds as possible, also, tpβ=β3, tuβ=β6 and tdβ=β2. If we consider the rectangle shown on the image by arrows, the average biathlete can move along the boundary in a clockwise direction in exactly 48 seconds. The upper left corner of this track is located in the square with the row number 4, column number 3 and the lower right corner is at square with row number 6, column number 7. Among other things the administration wants all sides of the rectangle which boundaries will be the biathlon track to consist of no less than three squares and to be completely contained within the selected land.You are given the description of the given plot of land and all necessary time values. You are to write the program to find the most suitable rectangle for a biathlon track. If there are several such rectangles, you are allowed to print any of them. | In a single line of the output print four positive integers β the number of the row and the number of the column of the upper left corner and the number of the row and the number of the column of the lower right corner of the rectangle that is chosen for the track. | C | 667d00cac98b3bd07fc7c78be5373fb5 | 9dd73197b3360ac537f89cdfd525c982 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"constructive algorithms",
"data structures",
"binary search",
"brute force"
] | 1398409200 | ["6 7 48\n3 6 2\n5 4 8 3 3 7 9\n4 1 6 8 7 1 1\n1 6 4 6 4 8 6\n7 2 6 1 6 9 4\n1 9 8 6 3 9 2\n4 5 6 8 4 3 7"] | null | PASSED | 2,300 | standard input | 4.5 seconds | The first line of the input contains three integers n, m and t (3ββ€βn,βmββ€β300, 1ββ€βtββ€β109) β the sizes of the land plot and the desired distance covering time. The second line also contains three integers tp, tu and td (1ββ€βtp,βtu,βtdββ€β100) β the time the average biathlete needs to cover a flat piece of the track, an ascent and a descent respectively. Then n lines follow, each line contains m integers that set the heights of each square of the given plot of land. Each of the height values is a positive integer, not exceeding 106. | ["4 3 6 7"] | #include <stdio.h>
#include <stdlib.h>
#define INF 100000000000LL
#define lli long long int
int land[305][305];
lli hl[305][305];
lli vd[305][305];
lli hr[305][305];
lli vu[305][305];
int dummy2;
int bi, bk, bj, bp;
lli delta;
void binary_search(int l, int r, int t, int i, int k, int j) {
int mid;
lli sum;
mid = (l + r) / 2;
while(l <= r) {
sum = vu[i][j] - vu[k][j] + hr[i][mid] - hr[i][j]
+ vd[k][mid] - vd[i][mid] + hl[k][j] - hl[k][mid];
if (llabs(t - sum) < delta) {
delta = llabs(t - sum);
bi = i;
bj = j;
bk = k;
bp = mid;
}
if (sum < t) {
l = mid + 1;
} else if (sum == t) {
break;
} else {
r = mid - 1;
}
mid = (l + r) / 2;
}
return;
}
int main(void) {
int n, m, t;
int tp, tu, td;
int i, j, k;
scanf(" %d %d %d", &n, &m, &t);
scanf(" %d %d %d", &tp, &tu, &td);
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
scanf(" %d", &land[i][j]);
}
}
for (i = 0; i < n; i++) {
hr[i][0] = 0;
for (j = 1; j < m; j++) {
hr[i][j] = hr[i][j - 1];
if (land[i][j] < land[i][j - 1]) {
hr[i][j] += td;
} else if (land[i][j] == land[i][j - 1]) {
hr[i][j] += tp;
} else {
hr[i][j] += tu;
}
}
hl[i][m - 1] = 0;
for (j = m - 2; j >= 0; j--) {
hl[i][j] = hl[i][j + 1];
if (land[i][j] < land[i][j + 1]) {
hl[i][j] += td;
} else if (land[i][j] == land[i][j + 1]) {
hl[i][j] += tp;
} else {
hl[i][j] += tu;
}
}
}
for (j = 0; j < m; j++) {
vd[0][j] = 0;
for (i = 1; i < n; i++) {
vd[i][j] = vd[i - 1][j];
if (land[i][j] < land[i - 1][j]) {
vd[i][j] += td;
} else if (land[i][j] == land[i - 1][j]) {
vd[i][j] += tp;
} else {
vd[i][j] += tu;
}
}
vu[n - 1][j] = 0;
for (i = n - 2; i >= 0; i--) {
vu[i][j] = vu[i + 1][j];
if (land[i][j] < land[i + 1][j]) {
vu[i][j] += td;
} else if (land[i][j] == land[i + 1][j]) {
vu[i][j] += tp;
} else {
vu[i][j] += tu;
}
}
}
bi = bj = bk = bp = 0;
delta = INF;
for (i = 0; i < n; i++) {
for (k = i + 2; k < n; k++) {
for (j = 0; j < m; j++) {
binary_search(j + 2, m - 1, t, i, k, j);
}
}
}
printf("%d %d %d %d\n", bi + 1, bj + 1, bk + 1, bp + 1);
return 0;
} | |
Recently an official statement of the world Olympic Committee said that the Olympic Winter Games 2030 will be held in Tomsk. The city officials decided to prepare for the Olympics thoroughly and to build all the necessary Olympic facilities as early as possible. First, a biathlon track will be built.To construct a biathlon track a plot of land was allocated, which is a rectangle divided into nβΓβm identical squares. Each of the squares has two coordinates: the number of the row (from 1 to n), where it is located, the number of the column (from 1 to m), where it is located. Also each of the squares is characterized by its height. During the sports the biathletes will have to move from one square to another. If a biathlete moves from a higher square to a lower one, he makes a descent. If a biathlete moves from a lower square to a higher one, he makes an ascent. If a biathlete moves between two squares with the same height, then he moves on flat ground.The biathlon track should be a border of some rectangular area of the allocated land on which biathletes will move in the clockwise direction. It is known that on one move on flat ground an average biathlete spends tp seconds, an ascent takes tu seconds, a descent takes td seconds. The Tomsk Administration wants to choose the route so that the average biathlete passes it in as close to t seconds as possible. In other words, the difference between time ts of passing the selected track and t should be minimum.For a better understanding you can look at the first sample of the input data. In this sample nβ=β6,βmβ=β7, and the administration wants the track covering time to be as close to tβ=β48 seconds as possible, also, tpβ=β3, tuβ=β6 and tdβ=β2. If we consider the rectangle shown on the image by arrows, the average biathlete can move along the boundary in a clockwise direction in exactly 48 seconds. The upper left corner of this track is located in the square with the row number 4, column number 3 and the lower right corner is at square with row number 6, column number 7. Among other things the administration wants all sides of the rectangle which boundaries will be the biathlon track to consist of no less than three squares and to be completely contained within the selected land.You are given the description of the given plot of land and all necessary time values. You are to write the program to find the most suitable rectangle for a biathlon track. If there are several such rectangles, you are allowed to print any of them. | In a single line of the output print four positive integers β the number of the row and the number of the column of the upper left corner and the number of the row and the number of the column of the lower right corner of the rectangle that is chosen for the track. | C | 667d00cac98b3bd07fc7c78be5373fb5 | 258c58ea9b15f0485bc27b44a137784d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"dp",
"constructive algorithms",
"data structures",
"binary search",
"brute force"
] | 1398409200 | ["6 7 48\n3 6 2\n5 4 8 3 3 7 9\n4 1 6 8 7 1 1\n1 6 4 6 4 8 6\n7 2 6 1 6 9 4\n1 9 8 6 3 9 2\n4 5 6 8 4 3 7"] | null | PASSED | 2,300 | standard input | 4.5 seconds | The first line of the input contains three integers n, m and t (3ββ€βn,βmββ€β300, 1ββ€βtββ€β109) β the sizes of the land plot and the desired distance covering time. The second line also contains three integers tp, tu and td (1ββ€βtp,βtu,βtdββ€β100) β the time the average biathlete needs to cover a flat piece of the track, an ascent and a descent respectively. Then n lines follow, each line contains m integers that set the heights of each square of the given plot of land. Each of the height values is a positive integer, not exceeding 106. | ["4 3 6 7"] | #include <stdio.h>
#include <stdlib.h>
#define INF 100000000000LL
#define lli long long int
int land[305][305];
lli hl[305][305];
lli vd[305][305];
lli hr[305][305];
lli vu[305][305];
int dummy;
int bi, bk, bj, bp;
lli delta;
void binary_search(int l, int r, int t, int i, int k, int j) {
int mid;
lli sum;
mid = (l + r) / 2;
while(l <= r) {
sum = vu[i][j] - vu[k][j] + hr[i][mid] - hr[i][j]
+ vd[k][mid] - vd[i][mid] + hl[k][j] - hl[k][mid];
if (llabs(t - sum) < delta) {
delta = llabs(t - sum);
bi = i;
bj = j;
bk = k;
bp = mid;
}
if (sum < t) {
l = mid + 1;
} else if (sum == t) {
break;
} else {
r = mid - 1;
}
mid = (l + r) / 2;
}
return;
}
int main(void) {
int n, m, t;
int tp, tu, td;
int i, j, k;
scanf(" %d %d %d", &n, &m, &t);
scanf(" %d %d %d", &tp, &tu, &td);
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
scanf(" %d", &land[i][j]);
}
}
for (i = 0; i < n; i++) {
hr[i][0] = 0;
for (j = 1; j < m; j++) {
hr[i][j] = hr[i][j - 1];
if (land[i][j] < land[i][j - 1]) {
hr[i][j] += td;
} else if (land[i][j] == land[i][j - 1]) {
hr[i][j] += tp;
} else {
hr[i][j] += tu;
}
}
hl[i][m - 1] = 0;
for (j = m - 2; j >= 0; j--) {
hl[i][j] = hl[i][j + 1];
if (land[i][j] < land[i][j + 1]) {
hl[i][j] += td;
} else if (land[i][j] == land[i][j + 1]) {
hl[i][j] += tp;
} else {
hl[i][j] += tu;
}
}
}
for (j = 0; j < m; j++) {
vd[0][j] = 0;
for (i = 1; i < n; i++) {
vd[i][j] = vd[i - 1][j];
if (land[i][j] < land[i - 1][j]) {
vd[i][j] += td;
} else if (land[i][j] == land[i - 1][j]) {
vd[i][j] += tp;
} else {
vd[i][j] += tu;
}
}
vu[n - 1][j] = 0;
for (i = n - 2; i >= 0; i--) {
vu[i][j] = vu[i + 1][j];
if (land[i][j] < land[i + 1][j]) {
vu[i][j] += td;
} else if (land[i][j] == land[i + 1][j]) {
vu[i][j] += tp;
} else {
vu[i][j] += tu;
}
}
}
bi = bj = bk = bp = 0;
delta = INF;
for (i = 0; i < n; i++) {
for (k = i + 2; k < n; k++) {
for (j = 0; j < m; j++) {
binary_search(j + 2, m - 1, t, i, k, j);
}
}
}
printf("%d %d %d %d\n", bi + 1, bj + 1, bk + 1, bp + 1);
return 0;
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | e05be0d3de98d2756b17f077cd2b0a4d | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int main(){
int i,n,sum=0,t,arr[105];
double s;
scanf("%d%d",&n,&t);
s=t;
for(i=1;i<=n;i++){
scanf("%d",&arr[i]);
s+=arr[i];
}
s/=n;
for(i=1;i<=n;i++)
if((s-arr[i])<0){
printf("-1");
return 0;
}
for(i=1;i<=n;i++)
printf("%f\n",s-arr[i]);
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 8313990239082abf073bf116d1dc21a6 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int main()
{
int a[110],b,n,i,j,k,sum=0,c=0;
float br[110],sum1;
scanf("%d %d",&n,&b);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
sum=sum+a[i];}
sum=sum+b;
sum1=(float)sum/(float)n;
for(i=0;i<n;i++)
br[i]=(sum1-(float)a[i]);
for(i=0;i<n;i++)
{
if(br[i]<0){
c++;break;}
}
if(c==0)
{
for(i=0;i<n;i++)
printf("%0.6f\n",br[i]);
}
else
printf("-1\n");
return 0;
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 8051bdfcf6b2c7141015a6f1e04781f4 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int main()
{
double k,b,a[100],sum=0,m,c=0;
int i,n;
scanf("%d%lf",&n,&b);
for( i=0;i<n;i++)
{
scanf("%lf",&a[i]);
sum+=a[i];
}
k=(sum+b)/n;
for( i=0;i<n;i++)
{
m=k-a[i];
if(m<0)
{
printf("-1");
c++;
break;
}
}
if(c==0)
for(i=0;i<n;i++)
printf("%lf\n",k-a[i]);
return(0);
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 391bc0e31382360f53edd41c4537c401 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int main()
{
int i;
float n,b,s=0.0;
float c[100];
scanf("%f%f",&n,&b);
for(i=0;i<n;i++)
{
scanf("%f",&c[i]);
s+=c[i];
}
b=(b+s)/n;
for(i=0;i<n;i++)
{
if (b<c[i]){printf("-1");return(0);}
c[i]=b-c[i];
}
for(i=0;i<n;i++)
printf("%.6f\n",c[i]);
return(0);
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 7a13223f7ba0bf3993821730537c7a25 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
void main()
{
int i;
double n,b,c,max,m[101],a[101];
while(scanf("%lf%lf",&n,&b)!=EOF)
{
max=0;
c=b;
for(i=0;i<n;i++)
{
scanf("%lf",&m[i]);
if(m[i]>max)
max=m[i];
c=c+m[i];
}
c=c/n;
if(c<max)
{
printf("-1\n");
continue;
}
for(i=0;i<n;i++)
printf("%.6lf\n",c-m[i]);
}
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | acf0352df3c1850da28edbebc8b7582e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include <stdio.h>
#define MAXN 105
int n, b;
int a[MAXN], max_a = 0, sum_a = 0;
int main()
{
int i;
scanf("%d%d", &n, &b);
for (i = 0 ; i < n; ++i) {
scanf("%d", &a[i]);
if (max_a < a[i]) max_a = a[i];
sum_a += a[i];
}
if (b < max_a * n - sum_a) puts("-1");
else {
double extra = (double)(b - (max_a * n - sum_a)) / n;
for (i = 0; i < n; ++i)
printf("%.9lf\n", extra + (max_a - a[i]));
}
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | b0a65098557d817ee9c596b555bdca27 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int n,b,i,s=0,f=0;
double avg;
scanf("%d%d",&n,&b);
int *a=(int *)calloc(n,sizeof(int));
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
s=s+a[i];
}
avg=((double)(s+b))/n;
for(i=0;i<n;i++)
{
if(a[i]>avg)
{
f=1;
break;
}
}
if(f==1)
printf("-1\n");
else
{
for(i=0;i<n;i++)
printf("%lf\n",(avg-a[i]));
}
return 0;
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | c57ebd31e2760be62f5109c4f308402c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int main()
{
int n,b,i,c=0;double s=0.0,t;
scanf("%d%d",&n,&b);
(double)n;
(double)b;
int a[n];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
(double)a[i];
s=s+a[i];
}
t=(s+b)/n;
for(i=0;i<n;i++)
{
if((t-a[i])<0)
{printf("-1");
c++;
break;}
}
if(c==0)
{
for(i=0;i<n;i++)
{
printf("%lf\n",t-a[i]);}}
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 9a143fa00c569de19f46ebb23bce6364 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | main()
{
float b,s=0;
int n,i;
float k;
scanf("%d %f",&n,&b);
float a[n],c[n];
for(i=0;i<n;i++)
{ scanf("%f",&a[i]);
s+=a[i]; }
k=(float)((s+b)/n);
for(i=0;i<n;i++){
if((k-a[i])>=0) c[i]=(float) k-a[i];
else{ printf("-1");return 0;}}
for(i=0;i<n;i++)
printf("%.6f\n",c[i]);
return 0;
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | ae483b3ac7663a565a5fc95f3cdffacc | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
#include<stdlib.h>
int main(void){
int b,n,i;
double *mug,all=0,ave;
scanf("%d %d",&n,&b);
mug=(double *)calloc(n,sizeof(double));
for(i=0;i<n;i++) scanf("%lf",mug+i);
all+=b;
for(i=0;i<n;i++) all+=*(mug+i);
ave=all/n;
for(i=0;i<n;i++){
*(mug+i)=ave-*(mug+i);
if(*(mug+i)<0){
puts("-1");
return 0;
}
}
for(i=0;i<n;i++) printf("%.6f\n",*(mug+i));
free(mug);
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 214b321fc9c82991889dc1143e3ce32c | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,b,i,t=0;
scanf("%d%d",&n,&b);
float a[n],sum;
for(i=0,sum=0;i<n;++i)
{
scanf("%f",&a[i]);
sum+=a[i];
}
sum+=b;
float c[n],nkol;
nkol=sum/(float)n;
if(b>0)
{
for(i=0;i<n;++i)
{
c[i]=nkol-a[i];
if(c[i]<0)
t=-1;
}
}else
t=-1;
if(t!=-1)
{
for(i=0;i<n;++i)
{
printf("%.6f \n",c[i]);
}}
else
printf("%d",t);
return 0;
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 18e5776061b92ce421944269361d2bfe | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int main(){
int n , k;
scanf("%d %d", &n, &k);
int i,a[n],s = 0,max = -1;
for(i = 0; i < n; i++) {
scanf("%d", &a[i]);
s += a[i];
if(max < a[i]) max = a[i];
}
s += k;
double x = (1.0 * s)/n;
if(max > x) {printf("-1\n"); return 0;}
for(i = 0; i < n; i++) printf("%.6f\n",x - a[i]);
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 9a0442e58bc3b303de8882afb6a0e49e | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
#include<stdlib.h>
int main(void){
int b,i,n,sum,count=0,error=-1;
int *a;
double ave;
scanf("%d %d",&n,&b);
a=(int *)calloc(n,sizeof(int));
sum=0;
for(i=0;i<n;i++){
scanf("%d",(a+i));
sum+=*(a+i);
}
sum+=b;
ave=(double)sum/n;
//printf("%f\n",ave);
for(i=0;i<n;i++){
if(*(a+i)>ave){
count++;
}
}
if(count!=0){
printf("%d\n",error);
}else{
for(i=0;i<n;i++){
printf("%f\n",ave-*(a+i));
}
}
free(a);
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | fe1ec92de7e543082ad23660bc3ecc28 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include <stdio.h>
int a[100];
int main(int argc, char *argv[])
{
int n, i, s, m;
double b;
scanf("%d %lf", &n, &b);
for(i = 0; i < n; i ++)
scanf("%d", a + i);
s = 0;
m = a[0];
for(i = 1; i < n; i ++)
if(a[i] > m)
{
s += i * (a[i] - m);
m = a[i];
}
else
s += m - a[i];
if(b < s)
{
puts("-1");
return 0;
}
for(i = 0; i < n; i ++)
printf("%.8lf\n", m - a[i] + (b - s) / n);
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | d9a423a4093d6890f0f867255c09a5a4 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include <stdio.h>
#include <conio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int main (void){
int i,x,j,temp,f=0,max;
float b,n;
scanf("%f %f",&n,&b);
x=n;
int c[x];
float need[x];
for(i=0;i<n;i++){
scanf("%d",&c[i]);
need[i]=0;
}
max=c[0];
for(i=1;i<n;i++){
if(c[i]>max)
max=c[i];
}
for(i=0;i<n;i++){
need[i]=max-c[i];
b=b-need[i];
if(b<0){
f++;
break;
}
}
if(f)
printf("-1");
else {
b/=n;
for(i=0;i<n;i++){
need[i]+=b;
printf("%f\n",need[i]);
}
}
return 0;
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | c0a6fda8b716ee0455591abe0d00d4ed | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int main()
{
int n,i;
double b;
while(scanf("%d",&n)!=EOF)
{
double a[101]={0},sum,ave,res[101];
int flag=1;
scanf("%lf",&b);
sum=b;
for(i=0;i<n;i++)
{
scanf("%lf",a+i);
sum+=a[i];
}
ave=sum/n;
for(i=0;i<n;i++)
{
if(a[i]>ave)
{
flag=0;
break;
}
res[i]=ave-a[i];
}
if(flag)
for(i=0;i<n;i++)
printf("%lf\n",res[i]);
else
printf("-1\n");
}
return 0;
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | dbd09161b3d97ae257f987b3b675f3d5 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int main()
{
double rs,sy,a[102],max,ave;
int i;
while(scanf("%lf%lf",&rs,&sy)!=EOF)
{
max=-1;
for(i=1;i<=rs;i++)
{
scanf("%lf",&a[i]);
if(a[i]>max)
max=a[i];
sy=sy+a[i];
}
ave=sy/rs;
if(ave<max)
printf("-1\n");
else
{
for(i=1;i<=rs;i++)
printf("%lf\n",ave-a[i]);
}
}
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 105dd56564d97148a5c7737f0637ceec | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include <stdio.h>
#include <stdlib.h>
int main(void)
{
int n, b, i, t=0;
scanf("%d%d", &n, &b);
float a[n], sum;
for (i = 0, sum = 0; i < n; ++i)
{
scanf("%f",&a[i]);
sum+=a[i];
}
sum += (float)b;
float c[n], nkol;
nkol = sum / (float)n;
if (b > 0) {
for (i = 0; i < n; ++i) {
c[i] = nkol - a[i];
if (c[i] < 0) t=-1;
}
}
else t=-1;
if (t != -1) {
for(i = 0; i < n; ++i) {
printf("%.6f \n",c[i]);
}
}
else printf("%d",t);
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | ee53a7f982cb65ef8164f04916d8f250 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include <stdio.h>
#define in scanf
#define out printf
int main() {
char n, i, b, a[100]; float c[100], full, t;
in("%hhd %hhd", &n, &b);
for (i = 0; i < n; ++i) in("%hhd", a+i);
full = b;
for (i = 0; i < n; ++i) full += a[i]; full /= n;
for (i = 0; i < n; ++i)
if (a[i] > full) break;
else t = full - a[i], c[i] = t, b -= t;
if (i < n) out("-1\n");
else for (i = 0; i < n; ++i) out("%.6f\n", c[i]);
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 8f8ec738f103d5e4c0db1b425f077609 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | main()
{
float b,s=0;
int n,i;
float k;
scanf("%d %f",&n,&b);
float a[n],c[n];
for(i=0;i<n;i++)
{ scanf("%f",&a[i]);
s+=a[i]; }
k=(float)((s+b)/n);
for(i=0;i<n;i++){
if((k-a[i])>=0) c[i]=(float) k-a[i];
else{ printf("-1");return 0;}}
for(i=0;i<n;i++)
printf("%.6f\n",c[i]);
return 0;
} | |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | cc628fde8c4946317319a2e11beb35d9 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv) {
int n, b;
scanf("%d %d", &n, &b);
double arr[n];
double in_cap = 0;
int i;
for (i = 0; i < n; i++) {
scanf("%lf", &arr[i]);
in_cap += arr[i];
}
/*
if (in_cap > b) {
printf("-1\n");
return 0;
}
*/
double full = in_cap + b;
full = full / n;
for (i=0; i<n; i++){
if (arr[i] > full){
printf ("-1\n");
return;
}
}
for (i = 0; i < n; i++) {
arr[i] = full - arr[i];
printf("%.6lf\n", arr[i]);
}
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | f5ac436912dd6052e6d6caad0676294a | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
#include<math.h>
int main()
{
int n,max=0,i;
float b;
scanf("%d %f",&n,&b);
int a[100];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
max=max>a[i]?max:a[i];
}
for(i=0;i<n;i++)
{
a[i]=max-a[i];
b-=a[i];
}
if(b<0)
{
printf("-1");
return 0;
}
b/=n;
for(i=0;i<n;i++)
printf("%.6f\n",a[i]+b);
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 1db5c4ef63725d43d2676f64a4065190 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int main()
{
long long n;
long long int b;
long long int a[105]={0};
long long int max=0;
int i=0;
max=0;
double sum=0;
scanf("%lld %lld",&n,&b);
for(i=0;i<n;i++)
{
scanf("%lld",&a[i]);
sum+=a[i];
if(a[i]>max)
max=a[i];
}
double ans=0;
if(max*n>b+sum)
printf("-1\n");
else
{
ans=((b+sum)*1.0)/(1.0*n);
for(i=0;i<n;i++)
{
printf("%lf\n",ans-a[i]);
}
}
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 9c6fa0cd6cf968bf16bd5d59cd7ddc28 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include <stdio.h>
int main()
{
int n,a[105],sum,flag=1,i;
double b[105],s=0;
scanf("%d%d",&n,&sum);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
s+=a[i];
}
s+=sum;
s=s/n;
for(i=0;i<n;i++)
{
b[i]=s-a[i];
if(b[i]<0)
{
flag=0;
break;
}
}
if(flag==0)
printf("-1\n");
else
{
for(i=0;i<n;i++)
printf("%.6lf\n",b[i]);
}
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | d6eddb917c4b80a2237eab79af1dcb45 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int n;
double a[110],b,max=-1.0,need=0.0;
int main()
{
int i;
scanf("%d %lf",&n,&b);
for (i=0;i<n;i++)
{
scanf("%lf",a+i);
if (a[i]>max) { max=a[i]; }
}
for (i=0;i<n;i++) { need+=max-a[i]; }
if (need>b)
{
printf("-1\n");
}
else
{
for (i=0;i<n;i++)
{
printf("%.8f\n",max-a[i]+(b-need)/(double)n);
}
}
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | 62849084e0abedc8c08fdcca53e8deb7 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,b,a[10000],i,s=0;
double q;
scanf("%d %d", &n,&b);
for(i=1;i<=n;i++)
{
scanf("%d", &a[i]);
s+=a[i];
}
a[n+1] = 0;
q = (double)(s+b)/n;
for(i=1;i<=n+1;i++)
{
if (q-a[i]<0) break;
}
if (i!=n+2) printf("-1");
else
{
for(i=1;i<=n;i++) printf("%f\n", q-a[i]);
}
return 0;
}
| |
A group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the n mugs must be the same.Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has a1 milliliters of the drink, the second one has a2 milliliters and so on. The bottle has b milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously: there were b milliliters poured in total. That is, the bottle need to be emptied; after the process is over, the volumes of the drink in the mugs should be equal. | Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print n float numbers c1,βc2,β...,βcn, where ci is the volume of the drink to add in the i-th mug. Print the numbers with no less than 6 digits after the decimal point, print each ci on a single line. Polycarpus proved that if a solution exists then it is unique. Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma. | C | 65fea461d3caa5a932d1e2c13e99a59e | e182725e5d7c6c1fc23c3dbdfc34db25 | GNU C | standard output | 256 megabytes | train_000.jsonl | [
"math"
] | 1333897500 | ["5 50\n1 2 3 4 5", "2 2\n1 100"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line contains a pair of integers n, b (2ββ€βnββ€β100,β1ββ€βbββ€β100), where n is the total number of friends in the group and b is the current volume of drink in the bottle. The second line contains a sequence of integers a1,βa2,β...,βan (0ββ€βaiββ€β100), where ai is the current volume of drink in the i-th mug. | ["12.000000\n11.000000\n10.000000\n9.000000\n8.000000", "-1"] | #include<stdio.h>
int a[101], n, max = -1, i;
double b, c[101];
int main()
{
scanf("%d %lf", &n, &b);
for(i = 0; i < n; i++)
{
scanf("%d", &a[i]);
if(a[i] > max)
max = a[i];
}
for(i = 0; i < n; i++)
{
if(a[i] < max)
{
c[i] = max - a[i];
b -= c[i];
}
if(b < 0)
{
printf("-1");
return 0;
}
}
for(i = 0; i < n; i++)
{
printf("%lf\n",c[i] + b/n);
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.