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
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as a sum of three distinct positive fractions in form .Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that . Because Chloe can't ...
If the answer exists, print 3 distinct numbers x, y and z (1 ≀ x, y, z ≀ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1. If there are multiple answers, print any of them.
C
f60ea0f2caaec16894e84ba87f90c061
dfb3001e2dc120e0d6438c51055be68b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "number theory", "brute force", "math" ]
1481726100
["3", "7"]
null
PASSED
1,500
standard input
1 second
The single line contains single integer n (1 ≀ n ≀ 104).
["2 7 42", "7 8 56"]
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> int main(){ int n; scanf("%d",&n); if(n==1) printf("-1\n"); else printf("%d %d %d\n",n,n+1,n*(n+1)); return 0; }
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as a sum of three distinct positive fractions in form .Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that . Because Chloe can't ...
If the answer exists, print 3 distinct numbers x, y and z (1 ≀ x, y, z ≀ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1. If there are multiple answers, print any of them.
C
f60ea0f2caaec16894e84ba87f90c061
39a34849d720515ac88d74af9c34fefe
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "number theory", "brute force", "math" ]
1481726100
["3", "7"]
null
PASSED
1,500
standard input
1 second
The single line contains single integer n (1 ≀ n ≀ 104).
["2 7 42", "7 8 56"]
#include <stdio.h> int main(){ int n, x, y, z; scanf("%i", &n); if (n==1){ printf("-1"); } else{ x=n; y=n+1; z=x*y; printf("%i %i %i", x, y, z); } return 0; }
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as a sum of three distinct positive fractions in form .Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that . Because Chloe can't ...
If the answer exists, print 3 distinct numbers x, y and z (1 ≀ x, y, z ≀ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1. If there are multiple answers, print any of them.
C
f60ea0f2caaec16894e84ba87f90c061
e7eb4ad72106c01e0f276555e158177f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "number theory", "brute force", "math" ]
1481726100
["3", "7"]
null
PASSED
1,500
standard input
1 second
The single line contains single integer n (1 ≀ n ≀ 104).
["2 7 42", "7 8 56"]
#include <stdio.h> int main() { int n; scanf("%d",&n); if(n==1) printf("-1\n"); else printf("%d %d %d\n",n, n+1, n*(n+1)); return 0; }
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
9c70b74c4fad86a1c623ab7cc396f0f4
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main () { int a,b,c,x,y,i,t; scanf ("%d",&t); for (i=0;i<t;i++){ scanf ("%d %d %d",&a,&b,&c); if (b==0){ printf ("0\n"); } else{ x=c/2; if (x>b){ printf("%d\n",3*b); } else{ b=b-x; y=b/2; if (y>a) y=a; printf ("%d\n",3*(x+y)); } } } return 0; }
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
fee138b0970b27ca68bed1e1b16a7816
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int n,a,b,c,d,s,e,f,g; scanf("%d",&n); while(n--) { scanf("%d%d%d",&a,&b,&c); d=0; g=0; e=0; f=0; for(;c>=2&&b>=1;) { d=d+2; c=c-2; e=e+1; b=b-1; } for(;a>=1&&b>=2;) { f=f+1; a=a-1; g=g+2; b=b-2; } s=d+e+f+g; printf("%d\n",s); } return 0; }
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
356807b32aa17a7e6c637ce580baaebd
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int t,i,sum=0; scanf("%d",&t); for(i=0;i<t;i++) { int a,b,c; scanf("%d%d%d",&a,&b,&c); if(b>0&&b>=c/2) { sum+=c/2+((c/2)*2); b-=c/2; if(a>0&&a>=b/2) { sum+=b/2+((b/2)*2); ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
0d70f92a54d57453d6764747f3db8711
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
/****************************************************************************** Online C Compiler. Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. ***********************************************...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
725bb7b8b4f46c072437bdb4420fbf93
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> #include<stdlib.h> int min(int x,int y) { if(x<y) return x; else return y; } int main() { int a,b,c,x,n,i,s; scanf("%d",&n); for(i=1;i<=n;i++) { s=0; scanf("%d%d%d",&a,&b,&c); x=min(b,c/2); s+=3*x; b-=x; x=min(a,b/...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
9a306185b51b3e1372e00de417b15f36
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main() { int t,i,a,b,c,b1,b2,b3,s; scanf("%d", &t); for(i=0;i<t;i++) { s=0; scanf("%d %d %d", &a,&b,&c); while(b>=1&&c>=2) { b--; c-=2; s+=3; } while(a>=1&&b>=2) { ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
bcf3fe346ced9c56fc07c8fdaeb48ae7
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int t, a, b, c, i; scanf("%d", &t); while(t--) { scanf("%d %d %d",&a, &b, &c); int s=0; for(i=0; ;i++) { if(b>=1 && c>=2) { s = s + 3; b = b-1; c = c-2; } ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
1479bf0a13845528b8b49b9efa5e2be2
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main() { int q; scanf("%d",&q); while(q>0) { int a,b,c,stone=0; scanf("%d%d%d",&a,&b,&c); while(b>0&&c>1) { b--; c-=2; stone+=3; } while(a>0&&b>1) { a--; b-=2; ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
ada66a3f8760be7908e682be0601388b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main(){ int time,a,b,c; int x,y,z; scanf("%d",&time); for(int i=0;i<time;i++){ x=0;y=0;z=0; scanf("%d %d %d",&a,&b,&c); x=c/2; if(b<x){ z=z+3*b; printf("%d\n",z); }else if(b>=x){ z=z+3*x; b=b-x; y=b/2; if(a<y){ z=z+3*a; }else if(a>=...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
d6aea7740ec3743c6396e02e8751f4e3
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int x,a,b,c,p=0; scanf("%d",&x); while(x--) { scanf("%d %d %d",&a,&b,&c); while(b>0&&c>0) { if(b-1>=0&&c-2>=0) { p=p+3; b--; c=c-2; } else break; } while...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
9400b6e00229bd6c3a2a9b0793a65dbe
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int i,j[3],m,n,k,l,min=0,p; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&m,&k,&l); while(1){ if(k>=1 && l>=2){ min+=3; k=k-1; l=l-2; } else if(m>=1 && k>=2){ min+=3; m=m-1; k=k-2; } el...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
3d673ee277d08ea1fbe477420daf58d8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main(){ int t,i,a,b,c,count; scanf("%d",&t); for(i=1;i<=t;i++){ scanf("%d %d %d",&a,&b,&c); count=0; while(c>1&&b>0){ b--;c-=2;count+=3; } while(b>1&&a>0){ a--;b-=2;count+=3; } printf("%d\n",count); } ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
09d96d9c611e22b7dd32d84f2f71b9db
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main() { int t,a,b,c,s; scanf("%d",&t); while(t--) { s=0; scanf("%d %d %d",&a,&b,&c); if(c/2>=b) { s=s+3*b; } else { s=s+3*(c/2); b=b-(c/2); if(b/2>=a) s=s+(3*a); else s=s...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
d2bdae072fc37b3d8602d1805d9c8857
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main(){ long long int t,a,b,c,count=0,i; scanf("%lld",&t); for(i=0;i<t;i++) { scanf("%lld%lld%lld",&a,&b,&c); if(c==0) { while(a>0 && b>0) { a=a-1; b=b-2; count=co...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
eb653fbe4597c5e2deb522c58785b181
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++) { int a,b,c,x,y; scanf("%d%d%d",&a,&b,&c); if(b==0) printf("0\n"); else if(c/2>=b) printf("%d\n",b*3); else { y=b-c/2; if(y/2<=a) { x=(c/2)*3+(y/2)*3; printf("%d\n",x); } ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
b87d41377d29a6e54649fd438fec64ba
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> #include <stdlib.h> int main() { int n, a[101], b[101], c[101], x, i; scanf("%d", &n); for(i=0; i<n; i++) { scanf("%d %d %d", &a[i], &b[i], &c[i]); } for(i=0; i<n; i++) { if((c[i]/2)>=b[i]) printf("%d\n", b[i]*3); else { x = b[i]...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
344ed3bd21d777e3e90d997c6535d049
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> #define min(a,b) (a<b)?a:b; int main() { int t,a,b,c,cnt,mm; scanf("%d",&t); while(t--) { scanf("%d %d %d",&a,&b,&c); cnt=0; mm=min(b,c/2); if(mm>0) { cnt+=mm;b-=mm; } mm=min(a,b/2); if(mm>0) cnt+=mm; printf("%d\n",cnt*3); } return 0; }
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
5e767c0abb65b7e20bd60d5e30ec5913
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int t,a,b,c,n,i,m,e,f,p,q; scanf("%d",&t); for(i=1; i<=t; i++) { m=0; n=0; scanf("%d %d %d",&a,&b,&c); while(b>=1&&c>=2){ m=m+3; b--; c=c-2; } while(a>=1&&b>=2){ n=n+3; ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
7266664e38bfcf18b26bbdae602001cc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int t; scanf("%d", &t); int i; int a, b, c; int ans; for (i = 0; i < t; i++) { scanf("%d %d %d", &a, &b, &c); ans = 0; if (2 * b <= c) { ans = 3 * b; b = 0; } else { ans = c / 2 * 3; b -= ans / 3; } if (2 * a <= b) ans += 3 * a; else ans += b /...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
34aded60ddc26d32108ec495c2e475c7
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main(void) { // your code goes here int a,b,c,t; scanf("%d",&t); while(t>0) { t--; scanf("%d",&a); scanf("%d",&b); scanf("%d",&c); int t=0; int rem1=b/2; int rem2=c/2; int b1=b; int s1=0; int s2=0; if(b==0) t=0; else { ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
f89be47cba84882ccd0ff8b436661de0
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main() { int a,b,c,t,i; int ara[200]; scanf("%d",&t); for(i = 0;i < t;i++){ scanf("%d %d %d",&a,&b,&c); ara[i] = 0; if(b > 0){ while(b >= 1 && c >= 2){ ara[i] = ara[i] + 3; b--; c = c - 2; ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
bbe09394bfd0e1c61a287cdaf4bdac32
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int t,a,b,c,sum,j; scanf("%d",&t); for(j=0;j<t;j++) { scanf("%d%d%d",&a,&b,&c); sum=0; if(b==0) { printf("0\n"); } else { sum=0; if(b*2<=c) { sum=b*2+b; ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
fc82327eb1a3a9215c90383a80dad677
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int t;scanf("%d",&t); while(t--) { int a,b,c,ans=0;scanf("%d%d%d",&a,&b,&c); (b>c/2)?(ans+=c/2,b-=c/2):(ans+=b,b-=b); (a>b/2)?(ans+=b/2):(ans+=a); printf("%d\n",ans*3); } }
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
7886a9ebef1a75ae6072afd6c6dcab4d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main(){ int nCasos; scanf("%d", &nCasos); int pa, pb, pc; for(int i = 0; i < nCasos; i++){ scanf("%d %d %d", &pa, &pb, &pc); int piedras = 0; if (pb == 0){ printf("0\n"); }else{ while((pc >= 2) && (pb > 0)){ ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
686b844271006568fb4b2a0e919d2cb8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main() { int a,b,c,ans,t; scanf("%d", &t); while(t--){ ans=0; scanf("%d %d %d", &a, &b, &c); while(b>=1 && c>=2){ b-=1; c-=2; ans+=3; } while(a>=1 && b>=2){ a-=1; b-=2; ans+=3; } printf("%d\n", ans); ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
9bc4dedb7ea08af36fe6e8736d1f996a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main () { int tc,a,b,c,avg; scanf("%d",&tc); while(tc--) { scanf("%d %d %d",&a,&b,&c); avg=0; while(b>0 && c>1) { b-=1; c-=2; avg+=3; } while(a>0 && b>1) { a-=1; ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
b78ee45f247db528dd3bab2ba30c3daf
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int a,b,c,i,t,j; scanf("%d",&t); for(j=1;j<=t;j=j+1) { scanf("%d %d %d",&a,&b,&c); int count=0,result=0; for(i=1;i!=0;i=i+1) { if(b>=1 && c>=2) { b=b-1; c=c-2; count=count+3; ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
ae4cec7fac732ad2b80ec9167afce594
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> #include<conio.h> #include<math.h> int min(int a, int b) { if(a<b) { return a;} else { return b;} } int main() { int t,i,a,b,c,count=0,temp1,temp2,temp3,max; scanf("%d",&t); for(i=0;i<t;i++) { count=0; max=0; scanf("%d %d %d",&a,&b,&c...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
b8ac56d8c48eb08a853f8214086180f0
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> #include <stdlib.h> int main() { int n,a,b,c; int count[100]; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d %d %d",&a,&b,&c); count[i-1]=0; while(b-1>=0 && c-2>=0){ b-=1; c-=2; count[i-1]+=3; } while(a-1>=...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
57adc729214f43fd6a6a13c68825a5c3
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int a,b,c,k=0,v=0,n; scanf("%d",&n); while(v<n) { scanf("%d %d %d",&a,&b,&c); while(1) { if((b>=1)&&(c>=2)) { b=b-1; c=c-2; k++; } else if((a>=1)&&(b>=2)...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
34815ca561095e6f32730753ce182710
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int a,b,c,k=0; scanf("%d%d%d",&a,&b,&c); for(;b>=1&&c>=2;) { k+=3;; b=b-1; c=c-2; } for(;a>=1&&b>=2;) { k+=3; a=a-1; ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
cbb8360db463dd83b90951cbc34da611
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> void main() { int t,a,b,c; scanf("%d",&t); while(t--) { int s=0; scanf("%d%d%d",&a,&b,&c); while(b>0) { c=c-2; if(c<0) break; else { b--; s=s+3;} } while(b>0 && a>0) { a--; ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
82816a701fc148decdaee189360155f4
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t>0){ int a,b,c,d,sum =0; scanf("%d %d %d",&a,&b,&c); d = b; for(int i=0;i<d;i++){ if(b>0 && c>=2){ sum++; b = b-1; c = c - 2; } ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
d90f206f959b6be96e7520abcb66ed74
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main(){ int tcases; scanf("%d", &tcases); while(tcases--){ int a, b, c; scanf("%d %d %d", &a, &b, &c); int ans = 0; int i, j; for(i = 0;i <= 100;i++)for(j = 0;j <= 100;j++)if(i <= a && 2*i + j <= b && 2*j <= c){ if(ans < 3*(i + j)) ans = 3*(i + j); } printf("%d\n...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
f2ed5e9dce11688ff7e29e17b4440878
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main(){ int t, a, b, c, s; scanf("%d", &t); for(int i = 0; i < t ; i++){ scanf("%d%d%d", &a, &b, &c); s = 0; while(b > 0 && c > 1){ b--; c -= 2; s += 3; } while(a > 0 && b > 1){ a--; b...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
36ecf12ffe7555c85d00bdb157000fb9
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main(){ int time,a,b,c; int x,y,z; scanf("%d",&time); for(int i=0;i<time;i++){ x=0;y=0;z=0; scanf("%d %d %d",&a,&b,&c); x=c/2; if(b<x){ z=z+3*b; printf("%d\n",z); }else if(b>=x){ z=z+3*x; b=b-x; y=b/2; if(a<y){ z=z+3*a; }else if(a>=...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
ceadc1d0cf06fb236e1d02f0925ec7e7
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> int main(){ int t,x,y,z; scanf("%d", &t); while(t--){ int s=0; scanf("%d%d%d", &x, &y, &z); while(y>=1 && z>=2){ s+=3; y=y-1; z=z-2; } while(y>=2 && x>=1){ s+=3; y=y-2; x=x-1; ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
73f6c6e98ffe596cfc741e34ecba74b8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include <stdio.h> int main() { int n; int a,b,c,s=0,temp; scanf ("%d",&n); while (n--) { s=0; scanf ("%d %d %d",&a,&b,&c); if (b>0 && c>1) { temp=c/2; //printf ("%d \n",temp); if (temp>=b) { ...
Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations: take one stone from the first heap and two stones from the seco...
Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer Β β€” the maximum possible number of stones that Alice can take after making some operations.
C
14fccd50d5dfb557dd53f2896ed844c3
89a19870656ac4b3641f63c15fe19469
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "brute force" ]
1571319300
["3\n3 4 5\n1 0 5\n5 3 2"]
NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones...
PASSED
800
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$) Β β€” the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$)Β β€” the number of stones in the first...
["9\n0\n6"]
#include<stdio.h> #include<stdlib.h> #include<math.h> int main() { int t; scanf("%d",&t); for(int i=0;i<t;i++) { int a,b,c;int sum=0; scanf("%d%d%d",&a,&b,&c); c=c/2; if(b<=c) { sum=b*3; } else{ sum=c*3; ...
Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only $$$T$$$ seconds after coming. Fortunately, Adilbek can spend time w...
Print one integer β€” the expected value of the number of crosswords Adilbek solves in $$$T$$$ seconds, expressed in the form of $$$P \cdot Q^{-1} \bmod (10^9 + 7)$$$.
C
a44cba5685500b16e24b8fba30451bc5
a5953a3aa804a10717965b2444b49604
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "dp", "combinatorics", "two pointers", "number theory", "probabilities" ]
1563115500
["3 5\n2 2 2", "3 5\n2 1 2"]
NoteThe answer for the first sample is equal to $$$\frac{14}{8}$$$.The answer for the second sample is equal to $$$\frac{17}{8}$$$.
PASSED
2,400
standard input
2 seconds
The first line contains two integers $$$n$$$ and $$$T$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le T \le 2 \cdot 10^{14}$$$) β€” the number of crosswords and the time Adilbek has to spend, respectively. The second line contains $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le 10^9$$$), where $$$t_i$$$ is the...
["750000007", "125000003"]
#include <stdio.h> #define N 200000 #define MD 1000000007 #define INV2 ((MD + 1) / 2) int d_, x_, y_; void gcd_(int a, int b) { if (b == 0) d_ = a, x_ = 1, y_ = 0; else { int tmp; gcd_(b, a % b); tmp = x_ - a / b * y_, x_ = y_, y_ = tmp; } } int inv(int a) { gcd_(a, MD); return x_; } int ff[N + 1], g...
Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only $$$T$$$ seconds after coming. Fortunately, Adilbek can spend time w...
Print one integer β€” the expected value of the number of crosswords Adilbek solves in $$$T$$$ seconds, expressed in the form of $$$P \cdot Q^{-1} \bmod (10^9 + 7)$$$.
C
a44cba5685500b16e24b8fba30451bc5
a2a888fe9054f4508f4796e442503a8b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "dp", "combinatorics", "two pointers", "number theory", "probabilities" ]
1563115500
["3 5\n2 2 2", "3 5\n2 1 2"]
NoteThe answer for the first sample is equal to $$$\frac{14}{8}$$$.The answer for the second sample is equal to $$$\frac{17}{8}$$$.
PASSED
2,400
standard input
2 seconds
The first line contains two integers $$$n$$$ and $$$T$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le T \le 2 \cdot 10^{14}$$$) β€” the number of crosswords and the time Adilbek has to spend, respectively. The second line contains $$$n$$$ integers $$$t_1, t_2, \dots, t_n$$$ ($$$1 \le t_i \le 10^9$$$), where $$$t_i$$$ is the...
["750000007", "125000003"]
#include<stdio.h> #include<stdlib.h> #include<stdint.h> #include<inttypes.h> typedef int64_t i64; typedef int32_t i32; static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}} static i64 read_int(void){i...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
acf46322bde10a4d964b268f3a80e4f4
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
#include <stdio.h> #include <math.h> void merge(int a[],int l,int m,int r) { int l_n = m-l+1; int r_n = r-m; int L[l_n],R[r_n]; for(int i=0;i<l_n;i++) { L[i]=a[l+i]; } for(int i=0;i<r_n;i++) { R[i]=a[m+1+i]; } int i=0,j=0,k=l; while(i<l_n && j<r_n) {...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
c6865f156ffedb1cc0b95197966594fb
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
/* AUTHOR:AKASH JAIN * USERNAME:akash19jain * DATE:17/10/2019 */ // #include<algorithm> // #include <bits/stdc++.h> // using namespace std; #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<stdbool.h> #include<ctype.h> #define SC1(x) scanf("%lld",&x) #define SC2(x,y)...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
8e529de5fc8b5e0bb390486bf6d3f5df
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
#include <stdio.h> #include<string.h> #include<stdlib.h> long long int max(long long int a,long long int b){ if(a>b){ return a; } return b; } long long int cmp(const void *a,const void *b){ return *(long long int *)b-*(long long int*)a; } int main() { long long int i,j,test,k,m,l,r,flag=0,max...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
5c08bb66f0e7d25027302276f5582756
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
#include<stdio.h> #include<stdlib.h> long long int ele[400009]; long long int trick[400009]={0},b[400009]; int cmp(const void *a,const void *b){ long long int res = (*(long long int *)a - *(long long int *)b); if(res > 0){ return 1; } else if (res == 0){ return 0; } else{ return -1; } } int main(){ long ...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
69153bc6ec274ad0cded237bce888bd0
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define SZ 200010 typedef unsigned long long num; num getnum() { char c=getchar(); int flag=0; num v = 0; while(c < '0' || c > '9') { if(c == '-') flag = 1; c = getchar(); } while(c >= '0' && c <= '9') v = v * 10 + (c - '0'), c = getchar(); ...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
0a808e75bbe2a8e39638c5121be47ec3
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
// we will keep track on how many times each element was queried // then we sort both numbers array and "count" array and just "distribute" numbers so bigger ones are more frequently queried #define __STDC_FORMAT_MACROS #include <inttypes.h> #include <stdio.h> #include <stdlib.h> static inline int64_t fenwick_sum(int...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
bf6b17a8de7ee76b5af70f24150a9b25
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
#include <stdio.h> #include <stdlib.h> #define MAXN 234567 int arr[MAXN], reps[MAXN]; int sort(const void *a, const void *b) { return *(int *) b - *(int *) a; } int main() { int n, q, i; scanf("%d%d", &n, &q); for (i = 0; i < n; i++) { scanf("%d", arr+i); } for (i = 0; i < q; i++) ...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
5e5c2bf586eb6d414d66e84bc3b252cc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
#include <stdio.h> #include <stdlib.h> #define MAXN 234567 typedef long long int lli; int n, q, arr[MAXN], reps[MAXN]; int compare(const void *a, const void *b) { return *(int *) b - *(int *) a; } int main() { scanf("%d%d", &n, &q); for (int i = 0; i < n; i++) { scanf("%d", arr + i); } ...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
3279c16d77806080a1d6cdff9d173044
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
#include <stdio.h> #include <stdlib.h> #define MAXN 234567 typedef long long int lli; int n, q, arr[MAXN], reps[MAXN]; int compare(const void *a, const void *b) { return *(int *) a - *(int *) b; } int main() { scanf("%d%d", &n, &q); for (int i = 0; i < n; i++) { scanf("%d", arr + i); } ...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
fd3df42346368c29258e2ab0b2b30dac
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
#include <stdio.h> int mergesort(long long int a[],long long int s,long long int e) { long long int m=(s+e)/2,i; long long int b[e+1]; if(s==e)return 0; mergesort(a,s,m); mergesort(a,m+1,e); int x=s,y=m+1; for ( i = s; i < e+1 && (x<m+1 && y<e+1); i++) { if(a[x]<a[y]){ ...
The little girl loves the problems on array queries very much.One day she came across a rather well-known problem: you've got an array of $$$n$$$ elements (the elements of the array are indexed starting from 1); also, there are $$$q$$$ queries, each one is defined by a pair of integers $$$l_i$$$, $$$r_i$$$ $$$(1 \le l_...
In a single line print, a single integer β€” the maximum sum of query replies after the array elements are reordered. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
C
926ec28d1c80e7cbe0bb6d209e664f48
11a9eba5c0b9f1ff626507bae7fb1a22
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation", "sortings", "greedy" ]
1361719800
["3 3\n5 3 2\n1 2\n2 3\n1 3", "5 3\n5 2 4 1 3\n1 5\n2 3\n2 3"]
null
PASSED
1,500
standard input
1 second
The first line contains two space-separated integers $$$n$$$ ($$$1 \le n \le 2\cdot10^5$$$) and $$$q$$$ ($$$1 \le q \le 2\cdot10^5$$$) β€” the number of elements in the array and the number of queries, correspondingly. The next line contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 2\cdot10^5$$$) β€” th...
["25", "33"]
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> int aa[1234567]; int f[1234567]; void srand_(){ struct timeval tv; gettimeofday(&tv , NULL); srand(tv.tv_sec ^ tv.tv_usec); } int rand_(int n){ return (rand() * 76543LL + rand()) % n; } int compare(void const *a, void const *b){ int ia = *(int ...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
64875c602fdb18c7bdc67e05fb43dad0
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <stdio.h> int main() { int n, m, i, last; double result = 0.0; scanf("%d%d", &n, &m); last = 1; while (m--) { scanf("%d", &i); if (last < i) { result += i - last; } else if (last > i) { result += n - last + i; } last = i; } printf("%0.0lf", result); return 0; }
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
5bb3f2c0773f78ee2a4743725d3f85fc
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <stdio.h> #include <stdlib.h> int main() { int n, m; int i, j; long long int time = 0; scanf(" %d %d", &n, &m); int a[m]; for(i=0; i<m; i++){ scanf(" %d", &a[i]); } int max = a[0]; int temp = 1; for(i=0; i<m; i++){ if(a[i] >= max){ time += ...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
16fdbe0e7e2afafb03a944aeedcdbe4f
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include<stdio.h> int main() { __int64 n,m,t,s=0,i,x=1; scanf("%I64d %I64d",&n,&m); for(i=0;i<m;i++) { scanf("%I64d",&t); if(t==x); else if(t>x) {s+=t-x;x=t;} else {s+=t+n-x;x=t;} } printf("%I64d",s); return 0; }
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
e226c6b8247601684abbd108f74db6bd
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <stdio.h> int main() { long int n,m,a=1,b,i; long long int t=0; scanf("%ld%ld",&n,&m); for(i=1;i<=m;i++) { scanf("%ld",&b); if(a<=b) { t=t+(b-a); } else { t=t+((n-a)+b); } a=b; } printf("%lld",t)...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
b09327fa47bb2f3ff58ec868788b88d7
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include<stdio.h> main() { long long n,m,task,i,time,j; while(scanf("%lld %lld",&n,&m)!=EOF) { time=0; j=1; for(i=1; i<=m; i++) { scanf("%lld",&task); if(task>=j) { time=time+task-j; } else ...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
f7efd63e30a7f1b7b04e970d8260bb68
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <stdio.h> #include <stdlib.h> int main() { long long int num , task; long long int a[100000]; scanf("%I64d" , &num ); scanf("%I64d" , &task ); long long int i; for(i = 0; i < task; i++) { scanf("%I64d" , &a[i]); } long long int time = 0, j = 0 , position = 1 ,t; ...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
04e2b2152a1b45b46fb7792e240b4e59
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <stdio.h> #include <stdlib.h> int main() { long long n,m; scanf("%lli%lli",&n,&m); int i; long long a[m]; for(i=0;i<m;i++) scanf("%lli",&a[i]); long long time=a[0]-1; for(i=1;i<m;i++) { if(a[i]<a[i-1]) time+=(a[i]+n)-a[i-1]; else ...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
82ab7b8dc52422c5b0b4b2b9c944e48f
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include<stdio.h> int main(){ int n,m,i; int arr[100000]; scanf("%d %d",&n,&m); arr[0]=1; for(i=1;i<=m;i++){ scanf("%d",&arr[i]); } long long int sum=0; for(i=1;i<=m;i++){ if(arr[i]>=arr[i-1]){ sum+=arr[i]-arr[i-1]; } else{ sum+=arr[i]+n-arr[i-1]; } } printf("%lld",sum); return 0; }
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
819e8502d769a2dde285b3b373c16ed1
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include<stdio.h> int main(){ int n,m,i; int arr[100000]; scanf("%d %d",&n,&m); arr[0]=1; for(i=1;i<=m;i++){ scanf("%d",&arr[i]); } long long int sum=0; for(i=1;i<=m;i++){ if(arr[i]>=arr[i-1]){ sum+=arr[i]-arr[i-1]; } else{ sum+=arr[i]+n-arr[i-1]; } } printf("%I64d",sum); return 0; }
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
7280758ab0f02f996e868dfc52182f9c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <stdio.h> int go(int *, int, int); // Go to a location. Return the time taken to do so. int main() { int n, m, a, pos = 1, i; long long t = 0; scanf("%d%d", &n, &m); // Taking n, m for (i = 0 ; i < m ; i++) { scanf("%d", &a); t += (a - pos + n) % n; pos = a; } printf("%lld\n", t); return 0;...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
5d5f7247f987b8ff670263f189796193
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include<stdio.h> int main() { int p,q; long long int n,m,s=0,i; scanf("%I64d %I64d",&n,&m); long long int arr[m]; for(i=0;i<m;i++){ scanf("%I64d",&arr[i]); } s=s+arr[0]-1; for(i=0;i<(m-1);i++){ if(arr[i]>arr[i+1]){ q=n-arr[i]; p=arr[i+1]; s=...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
e930ad517c3cb9fac4f86c6899beaa0c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <stdio.h> #include <string.h> int num[100005]; int main() { int n, m, former; __int64 sum = 0; scanf("%d %d", &n, &m); int i; for(i = 1; i <= m ; i++) scanf("%d", num + i); for(i = 1, former = 1; i <= m; i++) { if(num[i] > former) sum += (num[i] - former)...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
ae25160462f479ab1c71536aaa484cef
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <Stdio.h> #include <String.h> int v[100010]; int main(void) { __int64 n,m; while(scanf("%I64d %I64d",&n,&m)!=EOF) { memset(v,0,sizeof(v)); __int64 ans,i; for(i=1;i<=m;i++) scanf("%I64d",&v[i]); for(ans=v[1]-1,i=2;i<=m;i++) { if(v[i]==v[i-1]) continue; else if(v[i]>v[i-1]) { ans+=...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
0ed000d7cd48cf1e2ec6b41f2f457cdb
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <stdio.h> int main() { int i, n, m, a[100001], moves, position = 1; long long count = 0; scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &a[i]); } for (i = 0; i < m; i++) { if (a[i] >= position) { moves = a[i] - position; } else { moves = n - position + a[i]; } count += mo...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
f2eed7a6cc0ed8d3902c86ce1b45a4cf
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include <stdio.h> #include <stdlib.h> int main() { int n,m,i; long long count=0; long long currentpos=1; scanf("%d%d",&n,&m); int x[m]; for(i=0;i<m;i++) { scanf("%d",&x[i]); if(x[i]>n||x[i]<0) { break; } } for(i=0;i<m;i++) ...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
06efb8f9792ca05c6d131e7a81f8e982
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include<stdio.h> int a[100010]; int abs(int x) { if (x<0) return -1*x; return x; } int main() { int n,m; scanf("%d%d",&n,&m); for (int i=1;i<=m;i++) { scanf("%d",&a[i]); a[i]--; } int cur=0; __int64 ans=0; for (int i=1;i<=m;i++) { if (a[i]>=cur) ans+=...
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.Xenia has recently moved into the ringroad house number 1. As a result, she's got m things to do. In order to complete the i-t...
Print a single integer β€” the time Xenia needs to complete all tasks. 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
2c9c96dc5b6f8d1f0ddeea8e07640d3e
16f47d7e7af4621b3d373a4e4069705a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1377531000
["4 3\n3 2 3", "4 3\n2 3 3"]
NoteIn the first test example the sequence of Xenia's moves along the ringroad looks as follows: 1 → 2 → 3 → 4 → 1 → 2 → 3. This is optimal sequence. So, she needs 6 time units.
PASSED
1,000
standard input
2 seconds
The first line contains two integers n and m (2 ≀ n ≀ 105, 1 ≀ m ≀ 105). The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ n). Note that Xenia can have multiple consecutive tasks in one house.
["6", "2"]
#include<stdio.h> int main() { long long int i,xp=1,n,m,t=0,a[100000]; scanf("%I64d%I64d",&n,&m); for(i=0;i<m;i++) scanf("%I64d",&a[i]); for(i=0;i<m;i++) { if(xp<a[i]) {t+=a[i]-xp; xp=a[i]; } else if(xp>a[i]) {t+=n-xp+a[i]; xp=a[i]; } }...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
a1f19872cea4e1abaf3580a1d6b0e6ca
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> typedef int ll; int main() { ll t,i,n,a[100005],count=0,flag=0,p,min; char str[100005]; scanf("%s",str); n=strlen(str); min=10; for(i=0;i<n;i++) { a[i]=str[i]-'0'; if(a[i]%2==0) { c...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
d40f8f5545c4292fd386c65a7078547c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include <stdio.h> #include <string.h> int main() { char num[100010],c; scanf("%s",num); int l=strlen(num),i=0; while(i<l) { if(num[i]<num[l-1] && !((num[i]-'0')%2)) { c=num[i]; num[i]=num[l-1]; num[l-1]=c; printf("%s\n",num); ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
82b388eb5a1c055e05d4540fa69a4c66
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include"stdio.h" int main() { char currency[100001], cu; char temp[100001];int maxi = 0; int i = 0 ,ans = 0 ,j; scanf("%s" , currency); for(i = 0; i < strlen(currency) - 1 ; ++i){ if((currency[i] - '0') % 2 == 0 && currency[strlen(currency) - 1] > currency[i] ){ maxi = 1; ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
521ad06329e69fd3984a951d52c0831b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include <stdio.h> #include <string.h> void swap(char *a, char *b) { *a = *a + *b - (*b = *a); } int main() { char num[200005]; scanf("%s", num); int n = strlen(num), i; for(i = 0; i < n; i++) { if((num[i] - '0')%2 == 0 && num[i] < num[n - 1]) { swap(num + i, num + n - ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
d1a9478f00ce985654d51f4b12031bd0
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<string.h> int main() { char str[100005]; scanf("%s",str); int curr,flag=0,i,len=strlen(str),min=99; for(i=0;i<len;i++) { if((str[i]-'0')%2==0) { flag=1; if((str[i]-'0')<(str[len-1]-'0')) { flag=2; str[i]=(str[len-1]+str[i])-(str[len-1]=str[i]); break; } /*i...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
a4481225d182747188a0f5831cbf773b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<string.h> int main() { long long int a,b,c,i=0,j,k,f=0; char s[110000]; scanf("%s",&s); a=strlen(s); for(i=a-1;i>=0;i--){ b=s[i]-'0'; if(b%2==0&&f==0){ k=s[i];c=i;f=1; //printf("%d\n",b/2); break; ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
0cb5153ab4d0a39c54ee9ce9d473c79b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<string.h> void swap(char *x,char *y) { char temp = *x; *x = *y; *y = temp; } int main() { int i, c=0, l, lo = 0; char num[1000000], c2[1000000], x; scanf("%s", num); l = strlen(num); for(i = 0 ; num[i] != '\0' ; i++) if((num[i] - 48) % 2 == 0 && num[i...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
deac9d72db4fcdbabd2429ffb777c168
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<math.h> #include<string.h> #include<ctype.h> int main() { char n[100001],temp; gets(n); int l=strlen(n),i,ck=0,t; for(i=0;i<l-1;i++) { if(n[i]=='0'||n[i]=='2'||n[i]=='4'||n[i]=='6'||n[i]=='8') ck=1; } if(ck==0) { printf("-1"); return 0; ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
2ab4aff0cf33445665a9b7a46d69c501
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include <stdio.h> #include <string.h> int main() { char a[100005]; scanf("%s",&a); int n = strlen(a); int i,st=10,sti=-1; int x = (int) a[n-1]; for (i = 0; i < n-1; i++) { int y = (int) a[i]; if (y % 2 == 0 && y < x) { sti = i; break; } else if (y % 2 == 0 && y > x) { sti = i; } } if (sti ==...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
66f5833445d7c1a655b2385f88124806
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
/* /~\. ( oo| Hello World! _\=/_ ___ # / _ \. ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
d2dac47b2b85ca35a24a6d83cb59907e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<string.h> int main(){ char a[100001]; scanf("%s", a); int i,l,index=-1,temp,flag=0; l = strlen(a); for(i=0;i<l-1;i++){ if(a[i]%2==0) { if(a[i]<a[l-1]) { flag=1; temp = a[i]; a[i] = a[l-1]; a[l-1] = temp; printf("%s",a); break; } else index = i;...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
eb234fb691fb0246b91833867dca431b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<stdlib.h> int main() { char a[100005]; int i,j=0,flag=0,loc,max=47; scanf("%s",a); int x=strlen(a),temp; for(i=0;i<(x-1);i++) { if((a[i]-48)%2==0) { if(a[x-1]>a[i]) { flag=1; max=a[i]; loc=i; break; ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
63607c73d81384ce2727ee9c8370e3b6
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<stdlib.h> int main() { char a[100005]; int i,j=0,flag=0,loc,max=47; scanf("%s",a); int x=strlen(a),temp; for(i=0;i<(x-1);i++) { if((a[i]-48)%2==0) { if(a[i]>max&&a[x-1]>a[i]) { flag=1; max=a[i]; loc=i; break...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
b5e043f8dde744a97275fd39756ba67a
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include"stdio.h" int main() { char currency[100001], cu; char temp[100001];int maxi = 0; int i = 0 ,ans = 0 ,j; scanf("%s" , currency); for(i = 0; i < strlen(currency) - 1 ; ++i){ if((currency[i] - '0') % 2 == 0 && currency[strlen(currency) - 1] > currency[i] ){ maxi = 1; ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
6c0c27962c65fa056bd1d26de2eb7d30
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include <stdio.h> #include <stdlib.h> int main() { char str[100000]; scanf("%s",str); int temp,ind,t,i,flag=0; int l=strlen(str); int max=0; int monkey,flag2=0; temp=0; int donkey=str[l-1]-48; for(i=l-2;i>=0;i--) { temp=(int)str[i] -48; if(temp%2==0 ) ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
da34834685234c79df138da5a67df34d
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include <stdio.h> #include <string.h> int main() { char a[100000],t; int i,l,b=0,c=0; scanf("%s",a); l=strlen(a); for(i=0;i<l-1;i++) { if(a[i]%2==0) { c=1; break; } } if(c==0) printf("-1"); else { for(i=0;i<l-1;i++) ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
e2e1ea5e51d5f02a43a78b7956decc40
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include <stdio.h> #include <stdlib.h> #include <string.h> void swap(char *a, char *b){ char temp=*a; *a=*b; *b=temp; } int main () { char num[100005]; gets(num); int i=0; int length=strlen(num); int flag=-1; int is_found=0; int counter=0; for (i=0;i<length;i++){ ...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
f95011e195c9e93c74665aa21d16c170
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<string.h> int main(){ int i=0,z,flag=0,even=0; char str[100002],temp; scanf("%s",str); int size=strlen(str); char x=str[size-1]; for(i=0;i<size;i++){ if(str[i]%2==0){ even=1; if(str[i]<x){ flag=1; str[size-1]=str[i]; str[i]=x; break; } else{ z...
Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer.Reliable sources have informed the financier Anton of some information about the exchange rate of c...
If the information about tomorrow's exchange rate is inconsistent, that is, there is no integer that meets the condition, print  - 1. Otherwise, print the exchange rate of currency you all know against the burle for tomorrow. This should be the maximum possible number of those that are even and that are obtained from t...
C
bc375e27bd52f413216aaecc674366f8
48e78f51ba5659d13865b7ea31d912e2
GNU C
standard output
256 megabytes
train_001.jsonl
[ "greedy", "math", "strings" ]
1422376200
["527", "4573", "1357997531"]
null
PASSED
1,300
standard input
0.5 seconds
The first line contains an odd positive integer nΒ β€” the exchange rate of currency you all know for today. The length of number n's representation is within range from 2 to 105, inclusive. The representation of n doesn't contain any leading zeroes.
["572", "3574", "-1"]
#include<stdio.h> #include<string.h> int main() { char a[1000000],c; scanf("%s",a); int n,i,j,t=0,k,f=-1; n=strlen(a); for(i=0;i<n-1;i++){ if(a[i]%2==0){f=i; if(a[i]<a[n-1]){ c=a[n-1];a[n-1]=a[i];a[i]=c;t=1;break;} } }if(f==-1)printf("-1\n"); else{if(t==0...
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n × m. There are...
Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.
C
f710958b96d788a19a1dda436728b9eb
0116b2ef534ca5bcb249f06925b9f19e
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1461515700
["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"]
null
PASSED
1,400
standard input
2 seconds
The first line of the input contains three integers n, m and q (1 ≀ n, m ≀ 100, 1 ≀ q ≀ 10 000)Β β€” dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≀ ti ≀ 3) that defines the type of the ...
["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"]
/* practice with Dukkha */ #include <stdio.h> #define N 100 #define M 100 #define Q 10000 int main() { static int tt[Q], rr[Q], cc[Q], xx[Q], aa[N][M]; int n, m, q, h, i, j, a; scanf("%d%d%d", &n, &m, &q); for (h = 0; h < q; h++) { scanf("%d", &tt[h]); if (tt[h] == 1) scanf("%d", &rr[h]), rr[h]--; else ...
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.That element can store information about the matrix of integers size n × m. There are...
Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value. If there are multiple valid solutions, output any of them.
C
f710958b96d788a19a1dda436728b9eb
20fbfecdbfd7e0f1cc89e5c3ba56240d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "implementation" ]
1461515700
["2 2 6\n2 1\n2 2\n3 1 1 1\n3 2 2 2\n3 1 2 8\n3 2 1 8", "3 3 2\n1 2\n3 2 2 5"]
null
PASSED
1,400
standard input
2 seconds
The first line of the input contains three integers n, m and q (1 ≀ n, m ≀ 100, 1 ≀ q ≀ 10 000)Β β€” dimensions of the matrix and the number of turns in the experiment, respectively. Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≀ ti ≀ 3) that defines the type of the ...
["8 2 \n1 8", "0 0 0 \n0 0 5 \n0 0 0"]
/* https://codeforces.com/contest/668/submission/56857696 (rainboy) */ #include <stdio.h> #define N 100 #define M 100 #define Q 10000 int main() { static int tt[Q], rr[Q], cc[Q], xx[Q], aa[N][M]; int n, m, q, h, i, j; scanf("%d%d%d", &n, &m, &q); for (h = 0; h < q; h++) { scanf("%d", &tt[h]); if (tt[h] == 1)...
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
In the first line print a single real number with exactly one decimal place β€” the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
C
06c7834aa4d06d6fcebfa410054f1b8c
f3d6286c94087b45fac6c6a319f019b4
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "sortings", "greedy" ]
1331478300
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2Β·0.5 + (3 + 3Β·0.5) = 1 + 4.5 = 5.5.
PASSED
1,700
standard input
3 seconds
The first input line contains two integers n and k (1 ≀ k ≀ n ≀ 103) β€” the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≀ ci ≀ 109) is an integer denoting the price of the i-th item, ti (1 ≀ ti ≀ 2) is an intege...
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
#include <stdio.h> #include <stdlib.h> typedef struct { int c; int i; } item; int cmp(const void *a, const void *b) { return ((item *)a)->c - ((item *)b)->c; } int d[1000][1000]; int main() { int n, k, p = 0, q = 0, i, j; double sum = 0; item a[1000], b[1000]; int c[1000] = {0}; ...
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
In the first line print a single real number with exactly one decimal place β€” the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
C
06c7834aa4d06d6fcebfa410054f1b8c
6bac4ce80da4529f13b1986336554a24
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "sortings", "greedy" ]
1331478300
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2Β·0.5 + (3 + 3Β·0.5) = 1 + 4.5 = 5.5.
PASSED
1,700
standard input
3 seconds
The first input line contains two integers n and k (1 ≀ k ≀ n ≀ 103) β€” the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≀ ci ≀ 109) is an integer denoting the price of the i-th item, ti (1 ≀ ti ≀ 2) is an intege...
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
//problema9 #include <stdio.h> #include <stdlib.h> typedef struct { int c; int i; } item; int cmp(const void *a, const void *b) { return ((item *)a)->c - ((item *)b)->c; } int d[1000][1000]; int main() { int n, k, p = 0, q = 0, i, j; double sum = 0; item a[1000], b[1000]; int c[10...
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
In the first line print a single real number with exactly one decimal place β€” the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
C
06c7834aa4d06d6fcebfa410054f1b8c
978c16b8cca471a4d4b5238c2cc44e43
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "sortings", "greedy" ]
1331478300
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2Β·0.5 + (3 + 3Β·0.5) = 1 + 4.5 = 5.5.
PASSED
1,700
standard input
3 seconds
The first input line contains two integers n and k (1 ≀ k ≀ n ≀ 103) β€” the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≀ ci ≀ 109) is an integer denoting the price of the i-th item, ti (1 ≀ ti ≀ 2) is an intege...
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
#include <stdio.h> #include <stdlib.h> typedef struct { int c; int i; } item; int cmp(const void *a, const void *b) { return ((item *)a)->c - ((item *)b)->c; } int d[1000][1000]; int main() { int n, k, p = 0, q = 0, i, j; double sum = 0; item a[1000], b[1000]; int c[1000] = {0}; ...
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
In the first line print a single real number with exactly one decimal place β€” the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
C
06c7834aa4d06d6fcebfa410054f1b8c
1116498108f9db651f35e8f0c62909f7
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "sortings", "greedy" ]
1331478300
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2Β·0.5 + (3 + 3Β·0.5) = 1 + 4.5 = 5.5.
PASSED
1,700
standard input
3 seconds
The first input line contains two integers n and k (1 ≀ k ≀ n ≀ 103) β€” the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≀ ci ≀ 109) is an integer denoting the price of the i-th item, ti (1 ≀ ti ≀ 2) is an intege...
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
#include <stdio.h> #include <stdlib.h> typedef struct { int c; int i; } item; int cmp(const void *a, const void *b) { return ((item *)a)->c - ((item *)b)->c; } int d[1000][1000]; int main() { int n, k, p, q, i, j; p = 0; q = 0; double sum = 0; item a[1000], b[1000]; int ...
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
In the first line print a single real number with exactly one decimal place β€” the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
C
06c7834aa4d06d6fcebfa410054f1b8c
b4c6cec97481efc83dbb032aef41752b
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "sortings", "greedy" ]
1331478300
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2Β·0.5 + (3 + 3Β·0.5) = 1 + 4.5 = 5.5.
PASSED
1,700
standard input
3 seconds
The first input line contains two integers n and k (1 ≀ k ≀ n ≀ 103) β€” the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≀ ci ≀ 109) is an integer denoting the price of the i-th item, ti (1 ≀ ti ≀ 2) is an intege...
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
#include<stdio.h> #include<math.h> struct item{ long int precio; int tipo; int entrada; }; typedef struct item item; void quicksort(item v[], int pri, int ult); void bubble(item v[],int n); int cargar(int k, int i); int main(){ int n,i,k,j,col,z; long int menor; double precioDes; scanf("%...
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
In the first line print a single real number with exactly one decimal place β€” the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
C
06c7834aa4d06d6fcebfa410054f1b8c
7ad67451b80c25d981bc457bc9c884ba
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "sortings", "greedy" ]
1331478300
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2Β·0.5 + (3 + 3Β·0.5) = 1 + 4.5 = 5.5.
PASSED
1,700
standard input
3 seconds
The first input line contains two integers n and k (1 ≀ k ≀ n ≀ 103) β€” the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≀ ci ≀ 109) is an integer denoting the price of the i-th item, ti (1 ≀ ti ≀ 2) is an intege...
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
//problema9 #include <stdio.h> #include <stdlib.h> typedef struct { int c; int i; } item; int cmp(const void *a, const void *b) { return ((item *)a)->c - ((item *)b)->c; } int d[1000][1000]; int main() { int n, k, p = 0, q = 0, i, j; double sum = 0; item a[1000], b[1000]; int c[10...
One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheape...
In the first line print a single real number with exactly one decimal place β€” the minimum total price of the items, including the discounts. In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where...
C
06c7834aa4d06d6fcebfa410054f1b8c
25f9b3dce2dc6691d771b7dc22de1165
GNU C
standard output
256 megabytes
train_001.jsonl
[ "constructive algorithms", "sortings", "greedy" ]
1331478300
["3 2\n2 1\n3 2\n3 1", "4 3\n4 1\n1 2\n2 2\n3 2"]
NoteIn the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2Β·0.5 + (3 + 3Β·0.5) = 1 + 4.5 = 5.5.
PASSED
1,700
standard input
3 seconds
The first input line contains two integers n and k (1 ≀ k ≀ n ≀ 103) β€” the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≀ ci ≀ 109) is an integer denoting the price of the i-th item, ti (1 ≀ ti ≀ 2) is an intege...
["5.5\n2 1 2\n1 3", "8.0\n1 1\n2 4 2\n1 3"]
#include <stdio.h> typedef struct art{ int pos; int p; int t; }art; void intercambiar(art * arti1 , art * arti2); void quicksort(art * articulo,int ini,int fin); int main(){ int n,k,x,j; int limite=0,totalc; double s=0; scanf("%d %d",&n,&k); totalc = k; art v[n],aux; for(x=0 ; x<n ; x++){ ...