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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 48f9183cc1665dfc267c6cc9e1b11481 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include <stdio.h>
long long min(long long a,long long b){
if(a>b)return b;
else return a;
}
long long max(long long a,long long b){
if(a>b)return a;
else return b;
}
int main(int argc, char *argv[])
{
int tc;
scanf("%d",&tc);
while(tc--){
long long n,i,sum=0,d,ss;
scanf("%lld",&n);
long long a[n+6],pref[n+6];
for(i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
for(i=1;i<=n;i++){
if(a[i]<0){
d=a[i]*(-1);
a[i]=min(sum-d,0);
sum=max(sum-d,0);
if(sum<=0)sum=0;
}
else{
sum+=a[i];
}
}
ss=0;
for(i=1;i<=n;i++)
if(a[i]<0){
ss+=a[i];
// printf("%lld\n",a[i]);
}
printf("%lld\n",ss*(-1));
}
} | |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 6f620f00d80427bfbfc784f1031e2b1b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include <stdio.h>
typedef long long ll;
int correct(ll *arr, int n, ll coins) {
for (int i=0; i < n; i++) {
coins += arr[i];
if (coins < 0)
return 0;
}
if (coins < 0)
return 0;
return 1;
}
int main() {
int T;
int n;
ll arr[(int)1e5+7];
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (int i=0; i < n; i++)
scanf("%lld", &arr[i]);
ll l=0, r=1e14+7;
ll mid= (l+r)/2;
while (r-l > 1) {
mid = (l+r)>>1;
if (correct(arr, n, mid))
r = mid;
else
l = mid;
}
if (correct(arr, n, l))
printf("%lld\n", l);
else if (correct(arr, n, mid))
printf("%lld\n", mid);
else if (correct(arr, n, r))
printf("%lld\n", r);
}
return 0;
}
| |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | b035b4b94866d8f45abf1319643b49de | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include<stdio.h>
int main()
{
long long int t,q,n,a[100001],i,x,y,z,k;
scanf("%lld",&t);
for(q=1;q<=t;q++)
{
x=0;
y=0;
z=0;
k=0;
scanf("%lld",&n);
for(i=1;i<=n;i++)
{scanf("%lld",&a[i]);
if(a[i]>0)
{x=x+a[i];}
else
{y=y+a[i];}
}
i=n;
while(i>=1)
{
if(a[i]<0)
{k=k+a[i];}
else
{
if(a[i]<(-1*k))
{
k=k+a[i];
z=z+a[i];
}
else
{
z=z-k;
k=0;
}
}
i--;
}
printf("%lld\n",x-z);
}
return 0;
}
| |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | c37afddf592cbd65fe3263498c9b9802 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include <stdio.h>
int main()
{
int t;
scanf("%d", &t);
while(t--){
int n, tmp;
long long int negsum = 0, possum = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%d", &tmp);
if(tmp < 0) {
if(possum > 0) {
possum += tmp;
if(possum < 0) {
negsum += possum;
possum = 0;
}
} else {
negsum += tmp;
}
} else if(tmp > 0) {
possum += tmp;
}
}
printf("%I64d\n", -negsum);
}
} | |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 8eed5e7189be05c7bbad697f967f7eb8 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include <stdio.h>
int main() {
int tests;
scanf("%d", &tests);
int ar[100000];
while (tests--) {
int n;
scanf("%d", &n);
for (int i=0; i<n; i++) {
scanf("%d", ar+i);
}
long long ans = 0;
for (int i=0; i<n; i++) {
ans += ar[i];
if (ans < 0)
ans = 0;
}
printf("%lld\n", ans);
}
}
| |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 947660a0ee32811054ce5333c645a7dc | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int n,j,c=0,s1=0,s2=0,i=0,p;
scanf("%lld",&n);
for(j=0;j<n;j++)
{
scanf("%lld",&p);
if(p>0) s1+=p;
else
{
s2=s2-p;
c=s2-s1;
if(c>i)
i=c;
}
}
printf("%lld\n",i);
}
return 0;
}
| |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | a6f59f220d319edb56a26dbaa14bc363 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int tc, n, i;
long long a, c, min;
scanf("%d", &tc);
while(tc--)
{
min = 0;
c = 0;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%lld", &a);
c += a;
if (min > c)
min = c;
}
printf("%lld\n", -min);
}
return 0;
} | |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | bcda0e7ac19bbc33bbd0870dfc3e79e5 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include<stdio.h>
int main(){
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
long long int a[100001];
long long int sum=0,sum_=0;
int j=0;
for(int i=0;i<n;i++){
scanf("%lld",&a[i]);
sum+=a[i];
if(sum>=0){
continue;
}
if(sum<0){
sum_+=-sum;
sum=0;
}
}
printf("%lld\n",sum_);
}
}
| |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 58ab44238769d2a68adae6875f6ffb86 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
int t;
scanf("%d", &t);
for(int x=0; x<t; x++){
int n;
scanf("%d", &n);
int a[n];
for(int i=0; i<n; i++)scanf("%d", &a[i]);
for(int i=0; i<n; i++){
if(a[i]>0){
for(int j=i+1;j<n; j++){
if(a[j]>=0)continue;
if(a[i]+a[j]>=0){
a[i] += a[j];
a[j]=0;
}
else {
a[j] += a[i];
a[i] = 0;
}
if(a[i]==0)break;
}
}
}
long long int c=0;
for(int i=0; i<n; i++){
if(a[i]>0)c+=a[i];
}
printf("%lld\n", c);
}
return 0;
}
| |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 9b740403718cb26678d51f6b70040059 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include<stdio.h>
int main()
{
int n, i, x, t;
long long int sum;
scanf("%d", &t);
while (t--)
{
scanf("%d", &n);
sum = 0;
for (i = 0; i<n; i++)
{
scanf("%d", &x);
sum += x;
if (sum < 0)
{
sum = 0;
}
}
printf("%lld\n", sum);
}
return 0;
} | |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 4c2b77b8692e88f868bb300bbd694c84 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include<stdio.h>
#include<math.h>
int main()
{
long long int t,i,j,n,a[1000000],b[1000000],p;
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
for(i=1;i<=n;i++)
scanf("%lld",&a[i]);
for(i=1;i<=n;i++)
if(a[i]>=0)
{ j=i; break;}
p=a[j];
for(i=j+1;i<=n;i++)
{
if(a[i]<0)
{
if(p+a[i]>=0) p+=a[i];
else p=0;
}
else p+=a[i];
}
printf("%lld\n",p);
}
} | |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 8f3948a51022a273607b0eb62d955705 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include<stdio.h>
int main()
{
int test;
scanf("%d",&test);
while(test--)
{
long long int m,j,d=0,sum1=0,sum2=0,i=0,x;
scanf("%lld",&m);
for(j=0;j<m;j++)
{
scanf("%lld",&x);
if(x>0)
{
sum1=sum1+x;
}
else
{
sum2=sum2-x;
d=sum2-sum1;
if(d>i)
{
i=d;
}
}
}
printf("%lld\n",i);
}
return 0;
}
| |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | cbdc5543bbeae392c49f36bfa9bd8f96 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include<stdio.h>
typedef long long ll;
ll nnn(ll a,ll b)
{
return a<b?a:b;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
ll ar[n],tmp=0,cnt=0;
for(int i=0;i<n;i++)
scanf("%lld",&ar[i]);
for(int i=0;i<n;i++)
{
if(ar[i]>=0)
tmp+=ar[i];
else
{
ll min=nnn(tmp,abs(ar[i]));
ar[i]+=min;
cnt-=ar[i];
tmp-=min;
}
}
printf("%lld\n",cnt);
}
return 0;
} | |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | f37bfe2f5ac17af1a445cb7fd727b331 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
long long int i,a,b,j,y,x,m,cur=0,n,t,c1,c2,n1,n2,m1,m2,te,tem,temp,ar[200005];
scanf("%lld",&t);
for(i=0;i<t;i++)
{
long long int sum=0,max=0,ans=0,tl=0,k=1,w=0;
scanf("%lld",&n);
for(j=0;j<n;j++)
{
scanf("%lld",&ar[j]);
sum+=ar[j];
if(sum<max)
max=sum;
}
printf("%lld\n",-max);
}
return 0;
}
| |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 0fa8eec93149c98833f467aaeb448ad7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include<stdio.h>
int main(){
int t; scanf("%d",&t);
while(t--){
int n; scanf("%d",&n);
long long int a[n];
for(int i=0;i<n;i++){scanf("%lld",&a[i]);}
long long int count=0,sum=0;
for(int i=n-1;i>=0;i--){
if(a[i]<0){sum=sum-a[i];}
else if(a[i]>0){
if(sum>=a[i]){sum=sum-a[i];}
else{
count=count+a[i]-sum; sum=0;
}
}
}
printf("%lld\n",count);
}
}
| |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | 3e8078aabe900c191d499088cb3dd425 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | // 1405/B Array Cancellation
#include <stdio.h>
int main() {
int t,n;
long long tmp, sum;
scanf("%d",&t);
while (t--){
sum = 0;
scanf("%d",&n);
for (int i = 0; i < n; i++) {
scanf("%lld",&tmp);
sum += tmp;
if (sum < 0) {
sum = 0;
}
}
printf("%lld\n",sum);
}
return 0;
} | |
You're given an array $$$a$$$ of $$$n$$$ integers, such that $$$a_1 + a_2 + \cdots + a_n = 0$$$.In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$), decrement $$$a_i$$$ by one and increment $$$a_j$$$ by one. If $$$i < j$$$ this operation is free, otherwise it costs one coin.How many coins do you have to spend in order to make all elements equal to $$$0$$$? | For each test case, print the minimum number of coins we have to spend in order to make all elements equal to $$$0$$$. | C | bd0b14e53ade1207022464ebafdf8c9a | c3f678536d035a775d80c722a02fbcec | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"implementation"
] | 1599402900 | ["7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0"] | NotePossible strategy for the first test case: Do $$$(i=2, j=3)$$$ three times (free), $$$a = [-3, 2, 0, 1]$$$. Do $$$(i=2, j=1)$$$ two times (pay two coins), $$$a = [-1, 0, 0, 1]$$$. Do $$$(i=4, j=1)$$$ one time (pay one coin), $$$a = [0, 0, 0, 0]$$$. | PASSED | 1,000 | standard input | 1 second | Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements. The next line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is given that $$$\sum_{i=1}^n a_i = 0$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. | ["3\n0\n4\n1\n8\n3000000000\n0"] | #include <stdio.h>
#include <stdlib.h>
long long int min(long long int a,long long int b)
{
if(a<=b)
return(a);
else
return(b);
}
int main()
{
int t,i;
scanf("%d",&t);
for(i=0;i<t;i++)
{
long long int n,p=0,ans=0;scanf("%lld",&n);long long int a[n],j,k;for(j=0;j<n;j++)scanf("%lld",(a+j));
for(j=0;j<n;j++)
{
if(a[j]>0)
{
p=(p+a[j]);a[j]=0;
}
else
{
p=p-min(-a[j],p);
}
}
ans=p;
printf("%lld\n",ans);
}
return 0;
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | 3b5bf871fe7e4f77874cc0cff1d55a73 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include<stdio.h>
int main()
{char a[10000];
scanf("%s",a);
int j,i,k;
while(a[i]!='.')
i++;
if(a[i-1]<'9')
{
if(a[i+1]>='5')
a[i-1]++;
for(k=0;k<i;k++)
printf("%c",a[k]);}
else printf("GOTO Vasilisa.");
return 0;
} | |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | 8625b8ee68b626ce37b243937acb6cbb | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include <stdio.h>
#include <string.h>
int main()
{
char s1[1000], s2[1000];
scanf("%[^.].%s", s1, s2);
if (s1[strlen(s1) - 1] == '9')
printf("GOTO Vasilisa.");
else
if (s2[0] < '5')
printf("%s", s1);
else
s1[strlen(s1) - 1]++, printf("%s", s1);
return 0;
} | |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | f427d964840fe070a85e0d5189dc4cdb | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include<stdio.h>
#include<string.h>
int main()
{
int l,i,j,k;
char cg[1002];
scanf("%s",cg);
l=strlen(cg);
for(i=0;i<l;i++)
{
if(cg[i]=='.')
{
k=i;
break;
}
}
if((int)cg[i-1]!=(int)'9')
{
if((int)cg[i+1]<(int)'5')
{
cg[i-1]=cg[i-1];
for(i=0;i<k;i++)
printf("%c",cg[i]);
}
else
{
cg[i-1]=(char)((int)cg[i-1]+1);
for(i=0;i<k;i++)
printf("%c",cg[i]);
}
}
else printf("GOTO Vasilisa.");
return(0);
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | f5ff96c6549b18f971a77cee2d7580f5 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include<stdio.h>
#include<string.h>
int main(void){
char str[1024];
int i,j,k;
fgets(str,sizeof(str)/sizeof(char),stdin);
for(i=0;i<strlen(str);i++){
if(str[i]=='.'){
if(str[i-1]=='9'){
puts("GOTO Vasilisa.");
return 0;
}
if(str[i+1]>='5'){
str[i-1]++;
}
for(j=0;j<i;j++) putchar(str[j]);
putchar('\n');
return 0;
}
}
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | 004b1f73f178e308839029c55eed637b | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
int dot ;
char number[2000] ;
scanf("%s", number) ;
dot = 0 ;
while (number[dot] != '.')
{
dot++ ;
}
number[dot] = '\0' ;
if (number[dot - 1] < '9')
{
if (number[dot + 1] < '5')
{
printf("%s", number) ;
}
else
{
number[dot - 1]++ ;
printf("%s", number) ;
}
}
else
{
printf("GOTO Vasilisa.") ;
}
return 0 ;
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | 15a4072eca787526cf0290b21421c38e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char s[1001];
int i,j;
scanf("%s",s);
i=0;
while(s[i]!='.')
i++;
//printf("i=%d",i);
if(s[i-1]=='9')
printf("GOTO Vasilisa.");
else
{
// i++;
for(j=0;j<=i-2;j++)
printf("%c",s[j]);
// printf("s[i=%c\n",s[i-1]);
if(s[i+1]>52)
{
printf("%c",s[i-1]+1);
}
else printf("%c",s[i-1]);
}
return 0;
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | de4c3ff7faa06de333d94b526ff425e7 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include<stdio.h>
#include<string.h>
int main()
{
char a[1001];
int i,l;
while(gets(a))
{
for(i=0;a[i]!='.';i++);
l=i;
if(a[l-1]=='9')
puts("GOTO Vasilisa.");
else if(a[i+1]-'0'<5)
{
a[i]='\0';
for(i=0;i<l;i++)
{
if(a[i]!='0')
break;
}
if(i==l)
puts("0");
else
puts(&a[i]);
}
else
{
a[l-1]=a[l-1]+1;
a[l]='\0';
for(i=0;i<l;i++)
{
if(a[i]!='0')
break;
}
if(i==l)
puts("0");
else
puts(&a[i]);
}
}
return 0;
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | c337a558ceedb0fee5ae4b770a5b80a6 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
char ch[1001];
scanf("%s",ch);
int i;
for(i=0;ch[i]!='.';i++);
ch[i]='\0';
if(ch[i-1]=='9')
{
printf("%s","GOTO Vasilisa.");
}
else
{
if(ch[i+1]<'5')
{
printf("%s",ch);
}
else
{
ch[i-1]++;
printf("%s",ch);
}
}
return 0;
} | |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | a209c2309ac687c5a40c09c3842b0a17 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
char ch[1001];
scanf("%s",ch);
int i;
for(i=0;ch[i]!='.';i++);
ch[i]='\0';
if(ch[i-1]=='9')
{
printf("%s","GOTO Vasilisa.");
}
else
{
if(ch[i+1]<'5')
{
printf("%s",ch);
}
else
{
ch[i-1]++;
printf("%s",ch);
}
}
return 0;
} | |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | de39714be5b7aff5d5da8db5f8629bec | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include <stdio.h>
main() {
char s[1001];
int pos, i = 0;
scanf("%s", s);
while(s[pos] != '.') pos++;
if (s[pos - 1] == '9') {
printf("GOTO Vasilisa.");
return 0;
}
i = 0;
while (i != pos -1) {
printf("%c", s[i]);
i++;
}
printf("%c", s[pos + 1] < '5' ? s[pos - 1]: s[pos - 1] + 1);
return 0;
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | e21c3acc374969dc69035335bdccffea | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include<stdio.h>
int main()
{
char s[1001];
scanf(" %s", s);
int dot;
for(int i = 0; ; i++)
{
if(s[i] == '.')
{
dot = i;
break;
}
}
if(s[dot-1] == '9')
{
printf("GOTO Vasilisa.\n");
return 0;
}
if(s[dot+1] >= '5')
s[dot-1] = s[dot-1] +1;
for(int i = 0; i < dot; i++)
printf("%c", s[i]);
printf("\n");
return 0;
} | |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | c565f363236d6c44bd9fa2212604ecc5 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include<stdio.h>
int main()
{
char s[1002];
int ans;
int i,j,l;
scanf("%s",&s);
for(i=0;s[i]!='\0';i++)
{
if(s[i]=='.')
break;
}
l=i;
if(s[l-1]=='9')
{
printf("GOTO Vasilisa.\n");
}
else if(s[l+1]<'5')
{
for(i=0;i<l;i++)
printf("%c",s[i]);
printf("\n");
}
else
{
for(i=0;i<l-1;i++)
printf("%c",s[i]);
s[i]+=1;
printf("%c\n",s[i]);
}
return 0;
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | 1ab076400693b376237c73aaed19e479 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include <stdio.h>
#include <string.h>
int main()
{
char s1[1000], s2[1000];
int i;
scanf("%[^.]%*c%s", s1, s2);
if (s1[strlen(s1) - 1] == '9') {
puts("GOTO Vasilisa.");
} else {
for (i = 0; i < strlen(s1) - 1; i++) printf("%c", s1[i]);
if (s2[0] >= '5') {
printf("%c\n", s1[i] + 1);
} else {
printf("%c\n", s1[i]);
}
}
return 0;
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | 9cf575cec42b04355865a0a792ef321f | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include<stdio.h>
//#include<conio.h>
#include<string.h>
main()
{
char str[1001];
scanf("%s",&str);
int len=strlen(str);
int i=0,j;
while(str[i]!='.')
{
i++;
}
int k=i;
if(str[k-1]=='9')
printf("GOTO Vasilisa.");
else if(str[k+1]-48<5)
{
for(j=0;j<i;j++)
printf("%c",str[j]);
}
else if (str[k+1]-48>=5)
{
for(j=0;j<i-1;j++)
printf("%c",str[j]);
str[j]=str[j]+1;
//printf("%d",l);
//int n = l+1;
//char nu = n;
printf("%c",str[j]);
}
//getch();
return 0;
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | 9e28e40a16ec47739e7ed82f59fdc4aa | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>
int main()
{
char s[1111];
scanf("%s", s);
char* p = strchr(s, '.');
if (p[-1] == '9') {
printf("GOTO Vasilisa.\n");
return 0;
}
*p = '\0';
if (p[1] >= '5') {
p[-1]++;
}
printf("%s\n", s);
return 0;
}
| |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | d2608f7caa51b337daa3b30eaa187198 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include<stdio.h>
int main()
{
char num[1001];
int i,j;
scanf("%s",num);
for(i=0;num[i]!='.';i++)
;
if(num[i-1]!='9')
{
if(num[i+1]>='5')
{
for(j=0;j<i-1;j++)
printf("%c",num[j]);
printf("%c\n",num[j]+1);
}
else
{
for(j=0;j<i;j++)
printf("%c",num[j]);
printf("\n");
}
}
else
printf("GOTO Vasilisa.\n");
return 0;
} | |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | 498c53ccf1ed1fc62278e74649eb2e57 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include<stdio.h>
#include<stdlib.h>
int main(void)
{
char num[1002],integ[1002],fract[1002];
int car,i,j,n;
int k;
gets(num);
n=strlen(num);
for(i=0;i<=n-1 && num[i]!='.';i++)
integ[i]=num[i];
integ[i]='\0';
if(i!=n-1)
{
for(j=i+1;j<=n-1;j++)
{
fract[j-i-1]=num[j];
}
fract[j]='\0';
}
n=strlen(integ);
if(integ[n-1]=='9')
{
printf("GOTO Vasilisa.");
return 0;
}
else
{
if(fract[0]>='5')
{
integ[n-1]=integ[n-1]+1;
}
}
printf("%s",integ);
return 0;
} | |
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this: If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part. If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part. If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position. Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order? | If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes). | C | 3060ecad253a2b4d4fac39e91fcd6c95 | bccdb93d17eabe3bf43edd44d8f01851 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"strings"
] | 1311346800 | ["0.0", "1.49", "1.50", "2.71828182845904523536", "3.14159265358979323846", "12345678901234567890.1", "123456789123456789.999"] | null | PASSED | 800 | standard input | 2 seconds | The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data. | ["0", "1", "2", "3", "3", "12345678901234567890", "GOTO Vasilisa."] | #include <stdio.h>
#include <string.h>
char s[1005 ] , a, b , t[1001] ;
int n , i , j , k , p , q ;
int main()
{
scanf("%s", s) ;
n = strlen(s ) ;
for ( i = 0 ; i < n ; i++)
{
if( s[i] == '.' ) break ;
else
{
t[i] = s[i] ;
}
}
t[i] = '\0' ;
if ( s[i-1] == '9' ) printf("GOTO Vasilisa.") ;
else
{
if( s[i+1] < '5' ) printf("%s", t ) ;
else
{
t[i-1] = t[i-1] + 1 ;
printf("%s", t ) ;
}
}
return 0 ;
}
| |
Ilya is sitting in a waiting area of Metropolis airport and is bored of looking at time table that shows again and again that his plane is delayed. So he took out a sheet of paper and decided to solve some problems.First Ilya has drawn a grid of size n × n and marked n squares on it, such that no two marked squares share the same row or the same column. He calls a rectangle on a grid with sides parallel to grid sides beautiful if exactly two of its corner squares are marked. There are exactly n·(n - 1) / 2 beautiful rectangles.Ilya has chosen q query rectangles on a grid with sides parallel to grid sides (not necessarily beautiful ones), and for each of those rectangles he wants to find its beauty degree. Beauty degree of a rectangle is the number of beautiful rectangles that share at least one square with the given one.Now Ilya thinks that he might not have enough time to solve the problem till the departure of his flight. You are given the description of marked cells and the query rectangles, help Ilya find the beauty degree of each of the query rectangles. | For each query rectangle output its beauty degree on a separate line. | C | bc834c0aa602a8ba789b676affb0b33a | 06c19d481baf5537e4211cec391fa9da | GNU C11 | standard output | 512 megabytes | train_002.jsonl | [
"data structures"
] | 1504702500 | ["2 3\n1 2\n1 1 1 1\n1 1 1 2\n1 1 2 2", "4 2\n1 3 2 4\n4 1 4 4\n1 1 2 3"] | NoteThe first sample test has one beautiful rectangle that occupies the whole grid, therefore the answer to any query is 1.In the second sample test the first query rectangle intersects 3 beautiful rectangles, as shown on the picture below: There are 5 beautiful rectangles that intersect the second query rectangle, as shown on the following picture: | PASSED | 2,100 | standard input | 2 seconds | The first line of input contains two integers n and q (2 ≤ n ≤ 200 000, 1 ≤ q ≤ 200 000) — the size of the grid and the number of query rectangles. The second line contains n integers p1, p2, ..., pn, separated by spaces (1 ≤ pi ≤ n, all pi are different), they specify grid squares marked by Ilya: in column i he has marked a square at row pi, rows are numbered from 1 to n, bottom to top, columns are numbered from 1 to n, left to right. The following q lines describe query rectangles. Each rectangle is described by four integers: l, d, r, u (1 ≤ l ≤ r ≤ n, 1 ≤ d ≤ u ≤ n), here l and r are the leftmost and the rightmost columns of the rectangle, d and u the bottommost and the topmost rows of the rectangle. | ["1\n1\n1", "3\n5"] | /* practice with Dukkha */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 200000
#define M 200000
long long aa[M];
int n, m;
struct V {
int i, j, h;
} vv[N + M];
int compare(const void *a, const void *b) {
struct V *u = (struct V *) a;
struct V *v = (struct V *) b;
return u->i != v->i ? u->i - v->i : u->h - v->h;
}
int tt[N];
void update(int i) {
while (i < n) {
tt[i]++;
i |= i + 1;
}
}
int query(int i) {
int a = 0;
while (i >= 0) {
a += tt[i];
i &= i + 1;
i--;
}
return a;
}
void solve(int *ii, int *jj, int *pp) {
int i, h;
struct V *v;
for (i = 0; i < n; i++) {
v = &vv[i];
v->i = i, v->j = pp[i], v->h = -1;
}
for (h = 0; h < m; h++) {
v = &vv[n + h];
v->i = ii[h] - 1, v->j = jj[h] - 1, v->h = h;
}
qsort(vv, n + m, sizeof *vv, compare);
memset(tt, 0, n * sizeof *tt);
for (i = 0; i < n + m; i++) {
v = &vv[i];
if (v->h == -1)
update(v->j);
else {
int a = query(v->j);
aa[v->h] += (long long) a * (a - 1) / 2;
}
}
}
int main() {
static int pp[M], pp_[M], ll[M], rr[M], rr_[M], dd[M], uu[M], uu_[M];
int h, i, j, k, tmp;
long long a;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
scanf("%d", &pp[i]), pp[i]--;
for (h = 0; h < m; h++)
scanf("%d%d%d%d", &ll[h], &dd[h], &rr[h], &uu[h]), ll[h]--, dd[h]--, rr[h]--, uu[h]--;
a = (long long) n * (n - 1) / 2;
for (h = 0; h < m; h++) {
aa[h] = a;
k = ll[h];
aa[h] -= (long long) k * (k - 1) / 2;
k = dd[h];
aa[h] -= (long long) k * (k - 1) / 2;
k = n - 1 - rr[h];
aa[h] -= (long long) k * (k - 1) / 2;
k = n - 1 - uu[h];
aa[h] -= (long long) k * (k - 1) / 2;
}
solve(ll, dd, pp);
for (h = 0; h < m; h++)
uu_[h] = n - 1 - uu[h];
for (i = 0; i < n; i++)
pp_[i] = n - 1 - pp[i];
solve(ll, uu_, pp_);
for (h = 0; h < m; h++)
rr_[h] = n - 1 - rr[h];
for (i = 0, j = n - 1; i < j; i++, j--)
tmp = pp[i], pp[i] = pp[j], pp[j] = tmp;
solve(rr_, dd, pp);
for (i = 0, j = n - 1; i < j; i++, j--)
tmp = pp_[i], pp_[i] = pp_[j], pp_[j] = tmp;
solve(rr_, uu_, pp_);
for (h = 0; h < m; h++)
printf("%lld\n", aa[h]);
return 0;
}
| |
Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his friends, Jack must repeatedly go through stargates to get to this planet.Overall the galaxy has n planets, indexed with numbers from 1 to n. Jack is on the planet with index 1, and Apophis will land on the planet with index n. Jack can move between some pairs of planets through stargates (he can move in both directions); the transfer takes a positive, and, perhaps, for different pairs of planets unequal number of seconds. Jack begins his journey at time 0.It can be that other travellers are arriving to the planet where Jack is currently located. In this case, Jack has to wait for exactly 1 second before he can use the stargate. That is, if at time t another traveller arrives to the planet, Jack can only pass through the stargate at time t + 1, unless there are more travellers arriving at time t + 1 to the same planet.Knowing the information about travel times between the planets, and the times when Jack would not be able to use the stargate on particular planets, determine the minimum time in which he can get to the planet with index n. | Print a single number — the least amount of time Jack needs to get from planet 1 to planet n. If Jack can't get to planet n in any amount of time, print number -1. | C | d5fbb3033bd7508fd468edb9bb995d6c | 5222ade1c8385d9a3c86e6d024bfc759 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"data structures",
"binary search",
"graphs",
"shortest paths"
] | 1349105400 | ["4 6\n1 2 2\n1 3 3\n1 4 8\n2 3 4\n2 4 5\n3 4 3\n0\n1 3\n2 3 4\n0", "3 1\n1 2 3\n0\n1 3\n0"] | NoteIn the first sample Jack has three ways to go from planet 1. If he moves to planet 4 at once, he spends 8 seconds. If he transfers to planet 3, he spends 3 seconds, but as other travellers arrive to planet 3 at time 3 and 4, he can travel to planet 4 only at time 5, thus spending 8 seconds in total. But if Jack moves to planet 2, and then — to planet 4, then he spends a total of only 2 + 5 = 7 seconds.In the second sample one can't get from planet 1 to planet 3 by moving through stargates. | PASSED | 1,700 | standard input | 2 seconds | The first line contains two space-separated integers: n (2 ≤ n ≤ 105), the number of planets in the galaxy, and m (0 ≤ m ≤ 105) — the number of pairs of planets between which Jack can travel using stargates. Then m lines follow, containing three integers each: the i-th line contains numbers of planets ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi), which are connected through stargates, and the integer transfer time (in seconds) ci (1 ≤ ci ≤ 104) between these planets. It is guaranteed that between any pair of planets there is at most one stargate connection. Then n lines follow: the i-th line contains an integer ki (0 ≤ ki ≤ 105) that denotes the number of moments of time when other travellers arrive to the planet with index i. Then ki distinct space-separated integers tij (0 ≤ tij < 109) follow, sorted in ascending order. An integer tij means that at time tij (in seconds) another traveller arrives to the planet i. It is guaranteed that the sum of all ki does not exceed 105. | ["7", "-1"] | #include <stdio.h>
#include <string.h>
#define QLEN 100007
int n,m;
int e[200010][2],v[200010],p[100010];
int bgn[100010],len[100010],ban[100010],go[100010];
int q[100010],dis[100010];
short vis[100010];
void adde(int sn,int fn,int val,int id)
{
e[id][0] = fn; e[id][1] = p[sn]; p[sn] = id; v[id] = val;
}
int calc(int sn,int tim)
{
int head = bgn[sn],tail = bgn[sn]+len[sn]-1,mid;
if(!len[sn]) return tim;
while(head<tail)
{
mid = (head+tail)>>1;
if(ban[mid]>=tim) tail = mid;
else head = mid+1;
}
if(ban[head] != tim) return tim;
else return go[head];
}
void spfa()
{
int i,sn,fn,val;
int head = 1,tail = 2;
memset(dis,60,sizeof(dis));
q[1] = 1; dis[1] = 0; vis[1] = 1;
while(head != tail)
{
sn = q[head++];
for(i=p[sn];i;i=e[i][1])
{
fn = e[i][0];
val = calc(sn,dis[sn])+v[i];
if(dis[fn]<=val) continue;
dis[fn] = val;
if(vis[fn]) continue;
vis[fn] = 1; q[tail++] = fn;
if(tail>QLEN) tail = 1;
}
vis[sn] = 0;
if(head>QLEN) head = 1;
}
}
int main()
{
int i,j,sn,fn,val;
scanf("%d%d",&n,&m);
for(i=1;i<=m;i++)
{
scanf("%d%d%d",&sn,&fn,&val);
adde(sn,fn,val,i<<1);
adde(fn,sn,val,i<<1|1);
}
bgn[0] = 1;
for(i=1;i<=n;i++)
{
scanf("%d",&len[i]);
bgn[i] = bgn[i-1]+len[i-1];
for(j=bgn[i];j<bgn[i]+len[i];j++) scanf("%d",&ban[j]);
go[j-1] = ban[j-1]+1;
for(j-=2;j>=bgn[i];j--)
{
if(ban[j] == ban[j+1]-1) go[j] = go[j+1];
else go[j] = ban[j]+1;
}
}
spfa();
printf("%d",dis[n]<dis[0]?dis[n]:-1);
return 0;
} | |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. | In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. | C | a1f98b06650a5755e784cd6ec6f3b211 | 34f5cc4ce4639ee798ad9f2fafe8e28f | GNU C11 | standard output | 64 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1267963200 | ["3 2\n1 2\n2 7\n1 3"] | null | PASSED | 1,900 | standard input | 2 seconds | The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. | ["7\n2"] | #include <stdio.h>
#define MAX_PERSON 100005
typedef struct person_
{
int cap;
int id;
}person_t;
void min_heapify(person_t **map, int start, int end)
{
person_t *map_t = NULL;
int dad = start;
int son = dad * 2 + 1;
while (son <= end)
{
if ((son + 1 <= end) && (map[son]->cap > map[son + 1]->cap))
{
++son;
}
if (map[dad]->cap < map[son]->cap)
{
return;
}
map_t = map[dad];
map[dad] = map[son];
map[son] = map_t;
dad = son;
son = dad * 2 + 1;
}
}
void heap_sort(person_t **map, int n)
{
person_t *map_t = NULL;
int i = 0;
for (i = n / 2 - 1; i >= 0; --i)
{
min_heapify(map, i, n - 1);
}
for (i = n - 1; i > 0; --i)
{
map_t = map[0];
map[0] = map[i];
map[i] = map_t;
min_heapify(map, 0, i - 1);
}
}
int main()
{
person_t p[MAX_PERSON];
person_t* cata[MAX_PERSON];
int cata_cnt = 0;
person_t* kaya[MAX_PERSON];
int kaya_cnt = 0;
int cata_i = 0;
int kaya_i = 0;
int n = 0;
int v = 0;
int size = 0;
int ans = 0;
int i = 0;
scanf("%d%d", &n, &v);
for (i = 0; i < n; ++i)
{
scanf("%d%d", &size, &p[i].cap);
p[i].id = i + 1;
if (1 == size)
{
++kaya_cnt;
kaya[kaya_cnt - 1] = p + i;
}
else
{
++cata_cnt;
cata[cata_cnt - 1] = p + i;
}
}
heap_sort(cata, cata_cnt);
heap_sort(kaya, kaya_cnt);
ans = 0;
for (cata_i = 0; cata_i < cata_cnt; ++cata_i)
{
if (v < 2)
{
break;
}
ans += cata[cata_i]->cap;
v -= 2;
}
--cata_i;
for (kaya_i = 0; kaya_i < kaya_cnt; ++kaya_i)
{
if (v < 1)
{
break;
}
ans += kaya[kaya_i]->cap;
v -= 1;
}
while ((cata_i >= 0) && (kaya_i < kaya_cnt))
{
if ((kaya_i + 1 < kaya_cnt) && (cata[cata_i]->cap < kaya[kaya_i]->cap + kaya[kaya_i + 1]->cap))
{
ans = ans - cata[cata_i]->cap + kaya[kaya_i]->cap + kaya[kaya_i + 1]->cap;
--cata_i;
kaya_i += 2;
}
else if (cata[cata_i]->cap < kaya[kaya_i]->cap)
{
ans = ans - cata[cata_i]->cap + kaya[kaya_i]->cap;
--cata_i;
++kaya_i;
}
else
{
break;
}
}
--kaya_i;
printf("%d\n", ans);
for (i = 0; i <= cata_i; ++i)
{
printf("%d ", cata[i]->id);
}
for (i = 0; i <= kaya_i; ++i)
{
printf("%d ", kaya[i]->id);
}
return 0;
} | |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. | In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. | C | a1f98b06650a5755e784cd6ec6f3b211 | 686e5d4cbefcee0913e5d46f5e95607e | GNU C11 | standard output | 64 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1267963200 | ["3 2\n1 2\n2 7\n1 3"] | null | PASSED | 1,900 | standard input | 2 seconds | The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. | ["7\n2"] | #include <stdio.h>
#include <stdlib.h>
struct g
{
int x;
int y;
int c;
} n[100000],temp;
int ch[100000],u,s,c[100000];
void kuai(int a,int b)
{
if(a>=b)
return ;
int l=a,h=b;
temp=n[l];
while(l!=h)
{
while(l<h&&n[h].x<=temp.x)
h--;
if(l<h)
n[l++]=n[h];
while(l<h&&n[l].x>=temp.x)
l++;
if(l<h)
n[h--]=n[l];
}
n[l]=temp;
kuai(a,l-1);
kuai(l+1,b);
}
int main()
{
int i,m,n1,y=-2,j=0,P=0,Q=0,t;
scanf("%d %d",&m,&n1);
for (P=0; P<m; P++)
{
scanf("%d %d",&t,&u);
n[P].c=t;
if(t==1)
u*=2;
n[P].x=u;
n[P].y=P;
}
kuai(0,P-1);
Q=0;
int d=0,f=0,h=0;
for(i=0; i<P&&(n1-n[i].c)>=0; i++)
{
ch[h++]=n[i].y;
if(n[i].c==1)
{
Q+=((n[i].x)/2);
n1--;
}
else
{
Q+=n[i].x;
n1-=2;
}
}
if(n1==1)
{
int v;
for(j=i; j>=0; j--)
{
if(n[j].c==1)
{
if((n[j].x)/2<=n[i].x)
{
Q-=((n[j].x)/2);
ch[j]=n[i].y;
Q+=n[i].x;
}
for(v=i; v<P; v++)
if(n[v].c==1)
{
if((n[v].x+n[j].x)/2>n[i].x)
{
ch[h++]=n[v].y;
Q+=((n[i].x)/2);
ch[j]=n[j].y;
if((n[j].x)/2<=n[i].x)
{
Q+=((n[j].x)/2);
Q-=n[i].x;
}
}
break;
}
break;
}
}
}
printf("%d\n",Q);
for(i=0; i<h; i++)
printf("%d ",ch[i]+1);
return 0;
}
| |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. | In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. | C | a1f98b06650a5755e784cd6ec6f3b211 | 8cea787e26b3cfce67722c983ae774d8 | GNU C11 | standard output | 64 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1267963200 | ["3 2\n1 2\n2 7\n1 3"] | null | PASSED | 1,900 | standard input | 2 seconds | The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. | ["7\n2"] | #include <stdio.h>
#include <stdlib.h>
int t[100000],p[100000],w[100000],x[100000];
int cmp(const void *a,const void *b) {
return w[*(int *)b]-w[*(int *)a];
}
int main() {
int i,N,V,P,T,m=-1;
scanf("%i %i\n",&N,&V);
for (i=0;i<N;i++) scanf("%i %i\n",&t[i],&p[i]);
for (i=0;i<N;i++) w[i]=2/t[i]*p[i],x[i]=i;
qsort(x,N,sizeof *x,cmp);
P=0;
for (i=0;i<N&&V>=t[x[i]];i++) {
V-=t[x[i]],P+=p[x[i]];
if (t[x[i]]==1) m=x[i];
}
if (V&&m>=0&&i<N)
if (p[m]>p[x[i]]) m=-1;
else P+=p[x[i]]-p[m],i++;
else m=-1;
printf("%i\n",P);
while (i--) if (x[i]!=m) printf("%i ",x[i]+1);
return 0;
}
| |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. | In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. | C | a1f98b06650a5755e784cd6ec6f3b211 | 6a789d41561d1f92c3b3094f2efc650f | GNU C11 | standard output | 64 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1267963200 | ["3 2\n1 2\n2 7\n1 3"] | null | PASSED | 1,900 | standard input | 2 seconds | The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. | ["7\n2"] | #include <stdio.h>
#include <stdlib.h>
struct Barca {
int number;
int pi;
};
typedef struct Barca Barca;
int lodka_cmp_func (const void *a,const void *b) {
int x = ((Barca*) a)->pi;
int y = ((Barca *) b)->pi;
if ( x == y) {
return 0;
} else if ( x > y) {
return -1;
} else {
return 1;
}
}
int main(void) {
Barca b[100000];
Barca k[100000];
int numK = 0;
int numB = 0;
int bK = -1;
int bB = -1;
int temp;
int n;
int v;
scanf("%d", &n);
scanf("%d", &v);
for (int i = 0; i < n; ++i) {
scanf("%d", &temp);
if(temp == 1) {
scanf("%d",&b[numB].pi);
b[numB].number = i + 1;
numB++;
} else {
scanf("%d",&k[numK].pi);
k[numK].number = i + 1;
numK++;
}
}
qsort(b, numB, sizeof(Barca), lodka_cmp_func);
qsort(k, numK, sizeof(Barca), lodka_cmp_func);
while(v!=0) {
if ( v != 1) {
if ( (numK > bK + 1) && (numB > bB + 2) ) {
if ( k[bK+1].pi > b[bB+1].pi + b[bB+2].pi ) {
bK++;
v -= 2;
} else {
bB += 2;
v -= 2;
}
} else if ( numB > bB + 2 ) {
bB += 2;
v -= 2;
} else if ( (numK > bK + 1) && (numB > bB + 1) ) {
if ( k[bK+1].pi > b[bB+1].pi) {
bK++;
v -= 2;
} else {
bB += 1;
v -= 1;
}
} else if ( numB > bB + 1 ) {
bB += 1;
v -= 1;
} else if (numK > bK + 1) {
bK++;
v -= 2;
} else {
break;
}
} else {
if ( bB > -1) {
if (numB > bB + 1) {
if (numK > bK + 1) {
if ( k[bK+1].pi > b[bB+1].pi + b[bB].pi ) {
bK++;
bB--;
v--;
} else {
bB++;
v--;
}
} else {
bB++;
v--;
}
} else if (k[bK+1].pi > b[bB+1].pi) {
bK++;
bB--;
v--;
}
} else if (numB > 0) {
bB++;
v--;
} else {
break;
}
}
}
int maxVes = 0;
for(int i = 0; i < bB + 1; i++)
maxVes += b[i].pi;
for(int i = 0; i < bK + 1; i++)
maxVes += k[i].pi;
printf("%d\n", maxVes);
for(int i = 0; i < bB + 1; i++) {
if ( (i== bB) && (bK == -1)) {
printf("%d",b[i].number);
} else {
printf("%d ",b[i].number);
}
}
for(int i = 0; i < bK + 1; i++) {
if (i== bK) {
printf("%d",k[i].number);
} else {
printf("%d ",k[i].number);
}
}
return 0;
}
| |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. | In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. | C | a1f98b06650a5755e784cd6ec6f3b211 | 102d1c18b4f36c31fb5075462dff8404 | GNU C11 | standard output | 64 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1267963200 | ["3 2\n1 2\n2 7\n1 3"] | null | PASSED | 1,900 | standard input | 2 seconds | The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. | ["7\n2"] | #include <stdio.h>
#include <stdlib.h>
struct vehicle {
int p, i;
} *kk, *cc;
int compare(const void *a, const void *b) {
struct vehicle *va = (struct vehicle *) a;
struct vehicle *vb = (struct vehicle *) b;
return vb->p - va->p;
}
int main() {
int i, ik, ic, n, nk, nc, v, sum;
scanf("%d%d", &n, &v);
kk = malloc(sizeof(struct vehicle) * n);
cc = malloc(sizeof(struct vehicle) * n);
nk = nc = 0;
for (i = 0; i < n; i++) {
int t, p;
scanf("%d %d", &t, &p);
if (t == 1) {
kk[nk].p = p;
kk[nk].i = i + 1;
nk++;
} else {
cc[nc].p = p;
cc[nc].i = i + 1;
nc++;
}
}
qsort(kk, nk, sizeof(struct vehicle), compare);
qsort(cc, nc, sizeof(struct vehicle), compare);
ik = ic = 0;
sum = 0;
while (v > 0) {
if (ik == nk && (ic == nc || v == 1))
break;
if (ic == nc || v == 1 || kk[ik].p > cc[ic].p
|| (ik + 1 < nk && kk[ik].p + kk[ik + 1].p > cc[ic].p)) {
sum += kk[ik++].p;
v--;
} else {
sum += cc[ic++].p;
v -= 2;
}
}
printf("%d\n", sum);
for (i = 0; i < ik; i++)
printf("%d ", kk[i].i);
for (i = 0; i < ic; i++)
printf("%d ", cc[i].i);
printf("\n");
return 0;
}
| |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. | In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. | C | a1f98b06650a5755e784cd6ec6f3b211 | 8e1333a79821261bc0d97ef437308e98 | GNU C11 | standard output | 64 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1267963200 | ["3 2\n1 2\n2 7\n1 3"] | null | PASSED | 1,900 | standard input | 2 seconds | The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. | ["7\n2"] | #include <stdio.h>
#define MAX_PERSON 100005
typedef struct person_
{
int cap;
int id;
}person_t;
void min_heapify(person_t **map, int start, int end)
{
person_t *map_t = NULL;
int dad = start;
int son = dad * 2 + 1;
while (son <= end)
{
if ((son + 1 <= end) && (map[son]->cap > map[son + 1]->cap))
{
++son;
}
if (map[dad]->cap < map[son]->cap)
{
return;
}
map_t = map[dad];
map[dad] = map[son];
map[son] = map_t;
dad = son;
son = dad * 2 + 1;
}
}
void heap_sort(person_t **map, int n)
{
person_t *map_t = NULL;
int i = 0;
for (i = n / 2 - 1; i >= 0; --i)
{
min_heapify(map, i, n - 1);
}
for (i = n - 1; i > 0; --i)
{
map_t = map[0];
map[0] = map[i];
map[i] = map_t;
min_heapify(map, 0, i - 1);
}
}
int main()
{
person_t p[MAX_PERSON];
person_t* cata[MAX_PERSON];
int cata_cnt = 0;
person_t* kaya[MAX_PERSON];
int kaya_cnt = 0;
int cata_i = 0;
int kaya_i = 0;
int n = 0;
int v = 0;
int size = 0;
int ans = 0;
int i = 0;
scanf("%d%d", &n, &v);
for (i = 0; i < n; ++i)
{
scanf("%d%d", &size, &p[i].cap);
p[i].id = i + 1;
if (1 == size)
{
++kaya_cnt;
kaya[kaya_cnt - 1] = p + i;
}
else
{
++cata_cnt;
cata[cata_cnt - 1] = p + i;
}
}
heap_sort(cata, cata_cnt);
heap_sort(kaya, kaya_cnt);
ans = 0;
for (cata_i = 0; cata_i < cata_cnt; ++cata_i)
{
if (v < 2)
{
break;
}
ans += cata[cata_i]->cap;
v -= 2;
}
--cata_i;
for (kaya_i = 0; kaya_i < kaya_cnt; ++kaya_i)
{
if (v < 1)
{
break;
}
ans += kaya[kaya_i]->cap;
v -= 1;
}
while ((cata_i >= 0) && (kaya_i < kaya_cnt))
{
if ((kaya_i + 1 < kaya_cnt) && (cata[cata_i]->cap < kaya[kaya_i]->cap + kaya[kaya_i + 1]->cap))
{
ans = ans - cata[cata_i]->cap + kaya[kaya_i]->cap + kaya[kaya_i + 1]->cap;
--cata_i;
kaya_i += 2;
}
else if (cata[cata_i]->cap < kaya[kaya_i]->cap)
{
ans = ans - cata[cata_i]->cap + kaya[kaya_i]->cap;
--cata_i;
++kaya_i;
}
else
{
break;
}
}
--kaya_i;
printf("%d\n", ans);
for (i = 0; i <= cata_i; ++i)
{
printf("%d ", cata[i]->id);
}
for (i = 0; i <= kaya_i; ++i)
{
printf("%d ", kaya[i]->id);
}
return 0;
} | |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. | In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. | C | a1f98b06650a5755e784cd6ec6f3b211 | 5356b4407f52937c95e19d29cc1bc1d0 | GNU C11 | standard output | 64 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1267963200 | ["3 2\n1 2\n2 7\n1 3"] | null | PASSED | 1,900 | standard input | 2 seconds | The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. | ["7\n2"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
struct veh
{
int index;
int type;
int pow;
};
int partition(struct veh vehs[],int start,int end){
int pivot = vehs[end].pow,pIndex=start;
for(int i=start;i<end;i++){
if(vehs[i].pow>=pivot){
struct veh temp=vehs[i];
vehs[i]=vehs[pIndex];
vehs[pIndex]=temp;
pIndex++;
}
}
struct veh temp=vehs[pIndex];
vehs[pIndex]=vehs[end];
vehs[end]=temp;
return pIndex;
}
void quickSort(struct veh vehs[], int start, int end){
if(start<end){
int pIndex=partition(vehs,start,end);
quickSort(vehs,start,pIndex-1);
quickSort(vehs,pIndex+1,end);
}
}
int main(){
int n,v,temp1,temp2,c1=0,c2=0,t1=0,t2=0,t1v=0,t2v=0,c=0;
scanf("%d %d",&n,&v);//scan the number of vehicles and the volume
struct veh veh2[n];
struct veh veh1[n];
int index[n];
memset(index,0,sizeof(index));//set all cells to 0
memset(veh1,0,sizeof(veh1));//set all cells to 0
memset(veh2,0,sizeof(veh2));//set all cells to 0
for (int i=0;i<n;i++){//loop to scan the vehicle type and its power
scanf("%d %d",&temp1,&temp2);
if(temp1==1){
veh1[c1].index=i+1;
veh1[c1].pow=temp2;
t1+=temp2;t1v++;
c1++;
}
else{
veh2[c2].index=i+1;
veh2[c2].pow=temp2;
t2+=temp2;t2v+=2;
c2++;
}
}
if(t1v==0 && v==1){
printf("0");
return 0;
}
quickSort(veh1,0,t1v-1);
quickSort(veh2,0,(t2v/2)-1);
temp1=0;temp2=0;
c1=0,c2=0,c=0;
for(int i=0;i<n;i++){
if(temp1<v ){
if(veh1[c1].pow+veh1[c1+1].pow>veh2[c2].pow){
temp1++;
temp2+=veh1[c1].pow;
index[c]=veh1[c1].index;
c1++;
c++;
}
else if(temp1+2<=v){
temp1+=2;
temp2+=veh2[c2].pow;
index[c]=veh2[c2].index;
c2++;
c++;
}
else{
temp1++;
temp2+=veh1[c1].pow;
index[c]=veh1[c1].index;
c1++;
c++;
}
}
else{
break;
}
}
printf("%d\n",temp2);
for(int j=0;j<c;j++){
printf("%d ",index[j]);
}
return 0;
}
| |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. | In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. | C | a1f98b06650a5755e784cd6ec6f3b211 | d3dd0f111658b1af3267be0ef3c4d224 | GNU C11 | standard output | 64 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1267963200 | ["3 2\n1 2\n2 7\n1 3"] | null | PASSED | 1,900 | standard input | 2 seconds | The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. | ["7\n2"] | #include <stdio.h>
#include <stdlib.h>
int t[100000],p[100000],w[100000],x[100000];
int cmp(const void *a,const void *b) {//function is used in qsort to decide the relative order of elements at addresses
return w[*(int *)b]-w[*(int *)a];
}
int main() {
int i,N,V,P,T,m=-1;
scanf("%i %i\n",&N,&V);
for (i=0;i<N;i++) scanf("%i %i\n",&t[i],&p[i]);
for (i=0;i<N;i++) w[i]=2/t[i]*p[i],x[i]=i;//find
qsort(x,N,sizeof *x,cmp);//comparator function
P=0;
for (i=0;i<N&&V>=t[x[i]];i++) {
V-=t[x[i]],P+=p[x[i]];
if (t[x[i]]==1) m=x[i];
}
if (V&&m>=0&&i<N)
if (p[m]>p[x[i]]) m=-1;
else P+=p[x[i]]-p[m],i++;
else m=-1;
printf("%i\n",P);
while (i--) if (x[i]!=m) printf("%i ",x[i]+1);
return 0;
}
| |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body. | In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them. | C | a1f98b06650a5755e784cd6ec6f3b211 | bc56857e4f6c8a2561eb8ed3ddc7ce3a | GNU C11 | standard output | 64 megabytes | train_002.jsonl | [
"sortings",
"greedy"
] | 1267963200 | ["3 2\n1 2\n2 7\n1 3"] | null | PASSED | 1,900 | standard input | 2 seconds | The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file. | ["7\n2"] | /*
* Группа туристов собирается в водный поход. На лодочную базу прибыл арендованный грузовик, в который будут погружены байдарки и катамараны, а затем доставлены на место отправления.
* Известно, что все байдарки равны по размерам между собой (и занимают 1 куб. метр пространства), а катамараны равны по размерам между собой и в два раза больше байдарки
* (и занимают 2 куб. метра пространства).
*
* Каждое плавсредство обладает некоторой грузоподъемностью, причем даже неотличимые с виду плавсредства могут обладать разной грузоподъемностью.
*
* По заданному объему кузова грузовика и списку плавсредств (для каждого известен его тип и грузоподъемность) определите набор, который можно перевести и который обладает
* максимальной возможной грузоподъемностью. Объем кузова грузовика можно использовать максимально эффективно, то есть в кузов всегда можно погрузить плавсредство объемом не
* превышающее свободный объем кузова.
*
* Входные данные
* В первой строке записана пара целых чисел n и v (1 ≤ n ≤ 10^5; 1 ≤ v ≤ 10^9), где n это количество плавсредств на лодочной базе, а v — объем кузова грузовика в кубических метрах.
* Следующие n строк содержат описания плавсредств. Каждое описание это пара чисел ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 10^4), где ti это тип плавсредства (1 — байдарка, 2 — катамаран),
* а pi его грузоподъемность. Плавсредства нумеруются с единицы в порядке их появления во входном файле.
*
* Выходные данные
* В первую строку выведите искомую максимальную грузоподъемность набора. Во вторую строку выведите номера плавсредств, которые составляют оптимальный набор. Если решений несколько,
* выведите любое.
*
* Примеры
* Входные данные
* 3 2
* 1 2
* 2 7
* 1 3
*
* Выходные данные
* 7
* 2
*
* #жадные алгоритмы #сортировки
*/
#include <stdio.h>
#include <stdlib.h>
struct Lodka {
int number;
int pi;
};
typedef struct Lodka Lodka;
int lodka_cmp_func (const void *a,const void *b) {
int x = ((Lodka *) a)->pi;
int y = ((Lodka *) b)->pi;
if ( x == y) {
return 0;
} else if ( x > y) {
return -1;
} else {
return 1;
}
}
int main(void) {
Lodka baydarka[100000];
Lodka katamaran[100000];
int numKatamaran = 0;
int numBaydarka = 0;
int beremKatamaran = -1;
int beremBaydarka = -1;
int temp;
int n;
int v;
scanf("%d", &n);
scanf("%d", &v);
//printf("n = %d, v=%d\n",n,v);
for (int i = 0; i < n; ++i) {
scanf("%d", &temp);
if(temp == 1) {
scanf("%d",&baydarka[numBaydarka].pi);
baydarka[numBaydarka].number = i + 1;
numBaydarka++;
} else {
scanf("%d",&katamaran[numKatamaran].pi);
katamaran[numKatamaran].number = i + 1;
numKatamaran++;
}
}
qsort(baydarka, numBaydarka, sizeof(Lodka), lodka_cmp_func);
qsort(katamaran, numKatamaran, sizeof(Lodka), lodka_cmp_func);
/*
printf("Байдарки:\n");
for (int i = 0; i < numBaydarka; ++i) {
printf("номер: %d грузоподъёмность: %d\n",baydarka[i].number,baydarka[i].pi);
}
printf("Катамараны:\n");
for (int i = 0; i < numKatamaran; ++i) {
printf("номер: %d грузоподъёмность: %d\n",katamaran[i].number,katamaran[i].pi);
}
*/
while(v!=0) {
// если у нас есть место в грузовике для катамарана или двух байдарок
if ( v != 1) {
// если у нас есть свободый катамаран и две свободные байдарки
if ( (numKatamaran > beremKatamaran + 1) && (numBaydarka > beremBaydarka + 2) ) {
// если катамаран вмещает больше чем две байдарки
if ( katamaran[beremKatamaran+1].pi > baydarka[beremBaydarka+1].pi + baydarka[beremBaydarka+2].pi ) {
beremKatamaran++;
v -= 2;
} else {
beremBaydarka += 2;
v -= 2;
}
// если у нас нет свободного катамарана, но есть две свободные байдарки
} else if ( numBaydarka > beremBaydarka + 2 ) {
beremBaydarka += 2;
v -= 2;
// если у нас есть свободный катамаран и одна свободная байдарка
} else if ( (numKatamaran > beremKatamaran + 1) && (numBaydarka > beremBaydarka + 1) ) {
// если катамаран вмещает больше байдарки
if ( katamaran[beremKatamaran+1].pi > baydarka[beremBaydarka+1].pi) {
beremKatamaran++;
v -= 2;
} else {
beremBaydarka += 1;
v -= 1;
}
// если у нас нет свободного катамарана, но есть одна свободная байдарка
} else if ( numBaydarka > beremBaydarka + 1 ) {
beremBaydarka += 1;
v -= 1;
// если у нас есть свободный катамаран и нет свободных байдарок
} else if (numKatamaran > beremKatamaran + 1) {
beremKatamaran++;
v -= 2;
// если у нас нет свободного катамарана и нет свободных байдарок, но есть ещё место в грузовике
} else {
break;
}
} else {
// если в грузовике есть хотя бы одна байдарка
if ( beremBaydarka > -1) {
// если у нас есть свободная байдарка
if (numBaydarka > beremBaydarka + 1) {
// если у нас есть свободный катамаран
if (numKatamaran > beremKatamaran + 1) {
// если катамаран вмещает больше чем самая мелковместительная байдарка которая лежит в грузовике и самая вместительная свободная
if ( katamaran[beremKatamaran+1].pi > baydarka[beremBaydarka+1].pi + baydarka[beremBaydarka].pi ) {
beremKatamaran++;
beremBaydarka--;
v--;
} else {
beremBaydarka++;
v--;
}
} else {
beremBaydarka++;
v--;
}
// у нас нет свободных байдарок, но есть свободный катамаран
} else if (katamaran[beremKatamaran+1].pi > baydarka[beremBaydarka+1].pi) {
beremKatamaran++;
beremBaydarka--;
v--;
}
// если у нас есть хотя бы одна байдарка
} else if (numBaydarka > 0) {
beremBaydarka++;
v--;
} else {
break;
}
}
}
int maxVes = 0;
for(int i = 0; i < beremBaydarka + 1; i++)
maxVes += baydarka[i].pi;
for(int i = 0; i < beremKatamaran + 1; i++)
maxVes += katamaran[i].pi;
printf("%d\n", maxVes);
for(int i = 0; i < beremBaydarka + 1; i++) {
// если это последняя байдарка и в грузовике нет катамараны
if ( (i== beremBaydarka) && (beremKatamaran == -1)) {
printf("%d",baydarka[i].number);
} else {
printf("%d ",baydarka[i].number);
}
}
for(int i = 0; i < beremKatamaran + 1; i++) {
if (i== beremKatamaran) {
printf("%d",katamaran[i].number);
} else {
printf("%d ",katamaran[i].number);
}
}
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | e87942aff0f382815ec71dd9edb53640 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
int main()
{
int n,i,ara1[10000],store=0;
scanf("%d", &n);
for(i=0 ; i<n; i++)
{
scanf("%d", &ara1[i]);
if(ara1[i]==1)
{
store=1;
}
//ara2[i]=ara1[i];
}
if(store==1) printf("-1");
else printf("1");
/*k=n;
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
ara2[k]=ara1[i]+ara1[j];
//printf("%d %d\n", k,ara2[k]);
k++;
}
}
for(i=1; i<=10000; i++)
{
count=0;
for(j=0; j<k; j++)
{
if(i%ara2[j]==0)
{
//printf("i= %d\n", i);
count=1;
break;
}
}
if(count!=1)
{
printf("%d", i);
break;
}
}
i--;
//printf("%d\n", i);
if(i==10000)
printf("-1");*/
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 9201b455dbe91272f41592643e606c60 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int myarray[n];
int i;
for(i=0; i<n; i++)
{
scanf("%d",&myarray[i]);
}
for(i=0; i<n; i++)
{
if(myarray[i]==1)
{
printf("-1");
return 0;
}
}
printf("1");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | efa778aa226b1d336886f399191093fe | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main()
{
int x,n,i;
scanf("%d",&n);
for(i=0; i<n; i++)
{
scanf("%d",&x);
if(x==1)
{
printf("-1");
return 0;
}
}
printf("1");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | c4788799457880f6727ee958e2ef5de7 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
int main()
{
int n,a[1005],i,flag=0,min=1000001;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(min>a[i])
min=a[i];
if(a[i]==1)
flag=1;
}
if(flag==1)
printf("-1");
else
printf("1");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 9f7ffe05ff843b6b5b3a14c4688b76fc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,s,p;
scanf("%d",&n);
p=1;
while(n--)
{
scanf("%d",&s);
if(s==1) p=-1;
}
printf("%d",p);
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | ebb1c617b8112267c42200ada2958d1a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
long int n,a[1002],f=0,i,j,t,tmp,g=0;
scanf("%ld",&n);
for(i=1;i<=n;i++)
{
scanf("%ld",&a[i]);
if(a[i]==1)
{
f=1;
goto label;
}
}
for(i=1;i<=n-1;i++)
{
for(j=1;j<=n-i;j++)
{
if(a[j]>a[j+1])
{
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
}
for(i=1;i<=a[n];i++)
{
t=i;
while(t>0)
{
for(j=1;j<=n;j++)
{
if(t>=a[j])
{
t=t-a[j];
}
else
{
g++;
}
}
if(g==n)
{
goto label;
}
g=0;
}
}
label:
if(f==1)
{
printf("%d\n",-1);
}
else
{
printf("%ld",i);
}
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 14f900fdf58303389e84252f38da253b | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int a[n];
int min=1000001, prev_min;
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]<min)
{
min=a[i];
}
}
if(min==1)
{
printf("-1");
}
if(min>=2)
{
printf("%d\n",1);
}
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 332a37a2fa4494ddf37e9da9c508f7e3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | //http://codeforces.com/contest/560/problem/a
#include <stdio.h>
#include <stdlib.h>
int b[1000001]={0};
int compare(const void *a , const void *b){
int c = *(int*) a;
int d = *(int*) b;
if (c<d)
return -1;
else if(c==d){
return 0;
}
else return 1;
}
int main(void){
int i,ans=-1,temp;
int num;
int max=0;
scanf("%d",&num);
for(i=1;i<=num;i++){
scanf("%d",&temp);
b[temp]=1;
if(temp>max) max=temp;
}
if(b[1]){
ans=-1;
}
else{
ans=1;
}
/**for(i=1;i<=max;i++){
if(b[i]==0){
ans=i;
break;
}
}**/
printf("%d\n",ans);
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 17f1bf4d60611aeee77ea3c83db3d538 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
int main(void) {
int t,n,k,flag,i;
scanf("%d",&n);flag=0;
for(i=1;i<=n;i++)
{
scanf("%d",&k);
if(k==1)
{
flag=1;
break;
}
}
if(flag==1)
printf("-1");
else
printf("1");
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 17dda463da74eacb4d724ae170f48877 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
int main()
{
int n,i,j,f=0;
scanf ("%d",&n);
for (i=0;i<n;++i)
{
scanf ("%d",&j);
if (j==1)
f=1;
}
if (f==0)
puts ("1");
else
puts ("-1");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | bff3157b0a40bde3038bd7f806ae340e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
#include<malloc.h>
int main(){
int n,i,*a,c;
scanf("%d",&n);
a=(int *)malloc(n*sizeof(int));
c=1;
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]==1) c=-1;
}
printf("%d\n",c);
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 8c37780a7ba719082b60cf5a1d0dd847 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int n,a[10000],sum=0,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
for(i=0;i<n;i++)
{
if(a[i] == 1)
{
printf("%d",-1);
exit(0);
}
}
printf("1");
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | df580d0727b2416a409d84bfc9331c1f | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
main()
{
int x,y,i;
scanf("%d",&x);
for(i=0; i<x; i++)
{
scanf("%d",&y);
if(y==1)
{
printf("-1");
return 0;
}
}
printf("1");
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 31742fcf407ccc2b980c76c11b7417c4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
int main() {
int hm, flag = 0;
scanf("%d", &hm);
for (int i = 0; i < hm; i++) {
int a;
scanf("%d", &a);
if (a == 1) {
flag = 1;
printf("%d", -1);
break;
}
}
if (flag == 0) {
printf("%d", 1);
}
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | a4868f9900df2633e6080c811ad98518 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
#include<string.h>
int main()
{
int i, n, j, temp;
scanf("%d",&n);
int a[1005];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(j=0;j<n-1;j++)
for(i=0;i<n;i++)
{
if(a[i]>a[i+1])
{
temp=a[i+1];
a[i+1]=a[i];
a[i]=temp;
}
}
if(a[0]==1)
printf("-1");
else
printf("1");
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | d0687ed1d2455fe1fa19c57c0b486dc2 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main()
{
long long int n,i;
scanf("%lld",&n);
long long int a[n];
for(i=0;i<n;i++)
{
scanf("%lld",&a[i]);
if(a[i]==1)
{
printf("-1");
return 0;
}
}
printf("1");
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 9e73f43007a1436368ae3acc131ceb36 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
int main(void) {
int check=0,ar[1005],i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&ar[i]);
if(ar[i]==1)
check=1;
}
if(check==0)
printf("1\n");
else
printf("-1\n");
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 0e02edb29149be31f310a09a3e1987e3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main(){
int tc,i,n=0;
long long ara[100000];
scanf("%d",&tc);
for(i=0;i<tc;i++){
scanf("%I64d",&ara[i]);
if(ara[i]==1){
n=1;
}
}
if(n){
printf("-1\n");
return 0;
}
else
printf("1\n");
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 9c7eea50bd84d20e87370da4b3bf512d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<ctype.h>
#define MAX( a, b ) ( ( a > b) ? a : b )
#define MIN( a, b ) ( ( a < b) ? a : b )
#define FOR(ii,aa,bb) for(ii=aa;ii<bb;ii++)
int main () {
int x=0,n=0,s=0,i,j;
scanf("%d",&x);
FOR(i,0,x){
scanf("%d",&n);
if(n==1){
printf("-1");
return 0;}}
printf("1");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | ecb386a796def940ef802367139b76e6 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
int a[n];
int i,j,temp;
for(i=0;i<n;i++)
{
scanf("%d", &a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
if(a[0]==1)
{
printf("-1");
}
else printf("1");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 1e132d4a38c4c8242f44d123a8aed8c7 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
main()
{
long int a[1000],n,i;
int f;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
f=0;
for(i=0;i<n;i++)
{
if(a[i]==1)
{f=1;break;}
}
if(f==1)
printf("-1");
else
printf("1");
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | c9d0fc100b78bd874595833b04ffd5c0 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main(){
int n,i,b;
int l[1001];
scanf("%d",&n);
for(b=i=0;i<n;i++){
scanf("%d",&l[i]);
b=b | l[i]==1;
}
if(b){
printf("-1");
}else{
printf("1");
}
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 3653f696421a2cf9bf5a62fd018849b3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main()
{
int t,c=0;
scanf("%d",&t);
int i=0;
int a[t];
for(i=0;i<t;i++)
{
scanf("%d",&a[i]);
if(a[i]==1)
{
printf("-1");
c=1;
break;
}}
if(c==0)
printf("1");
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | b1005c039fd94f9f7113be864002ab1a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
#include <stdlib.h>
int a[1005];
int main()
{
int n=0,i=0,b=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i] == 1)
b = 1 ;
}
if(b == 1)
printf("-1");
else
printf("1");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 44f15e670678d1b73b654fd4b6d76e29 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main()
{
int n,num,i,f=0; scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&num);
if(num==1)
f=1;
}
if(f&1)
printf("-1");
else
printf("1");
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 2ff592ae584c813662457c0f2d549b68 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
#include<stdlib.h>
#define fr(i,a,n,k) for(i=a;i<n;i+=k)
#define ll long long
#define sc1(x) scanf("%ld",&x)
#define sc2(x,y) scanf("%ld%ld",&x,&y)
#define sc3(x,y,z) scanf("%ld%ld%ld",&x,&y,&z)
#define ss1(s) scanf("%s",s);
#define pr1(x) printf("%lld\n",x)
#define pr2(x,y) printf("%lld\t%lld\n",&x,&y);
#define pr3(x,y,z) printf("%lld\t%lld\t%lld\n",x,y,z);
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
int main()
{
long int n,i,nn,flag=0,sum=0;
sc1(n);
fr(i,0,n,1)
{
sc1(nn);
sum+=nn;
if(nn==1)
flag=1;
}
if(flag==1)
printf("-1\n");
else
printf("1\n");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 4b3f981a702ad795c7bf9413d184c3ca | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,i = 0,x= -1000;
scanf("%d",&n);
for(i=0;i<n && x != 1;i++)
{
scanf("%d",&x);
}
if(x==1)
{
printf("-1");
}
else
{
printf("1");
}
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | e88e42160f9909d9e7def794375c4e4f | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main()
{
int n,i;
scanf("%d",&n);
long int a[n];
for(i=0;i<n;i++)
{
scanf("%ld",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i]==1)
{
printf("-1");
return 0;
}
}
printf("1");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 79fffe4fbbe5e8eef6d4dc1ebf469ead | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
long long int q[1005];
int main()
{
int a,i;
scanf("%d",&a);
for(i=1 ; i<=a ; i++)
{
scanf("%d",&q[i]);
if(q[i]==1)
{
printf("-1\n");
return 0;
}
}
printf("1\n");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 60c105691fcd89d28fa2f5453b6a003d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | /*
* main.c
*
* Created on: Jul 22, 2015
* Author: michael
*/
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000
unsigned int n;
unsigned int banknotes[MAX];
unsigned int i;
int cmp(const void *a, const void *b)
{
return ( *(unsigned int*)a - *(unsigned int *)b );
}
int main()
{
// freopen("input.txt", "r", stdin);
scanf("%d", &n);
for ( i = 0; i < n; i++ )
{
scanf("%d", &banknotes[i]);
}
qsort(banknotes, n, sizeof(unsigned int), cmp);
printf("%d\n", banknotes[0] - 1 ? 1 : -1);
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 6f3803e57b4110f49239d2c08510bdf7 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i, n, noteVal[100005], flag = 0;
scanf("%d",&n);
memset(noteVal, 0, sizeof(noteVal));
for(i=1;i <= n;i ++)
scanf("%d",¬eVal[i]);
for(i=1;i <= n;i ++)
if(noteVal[i] == 1)
{
printf("-1\n");
flag = 1;
break;
}
if(!flag)
printf("1\n");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | ed7279f7f8a809dd8d8ed01152fc3391 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main()
{
int n,a,i;
while(scanf("%d",&n)!=EOF)
{
int flag=0;
for(i=0;i<n;i++)
{
scanf("%d",&a);
if(a==1)
flag=1;
}
if(flag==1)
printf("-1\n");
else
printf("1\n");
}
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 97d85a7891f85bfa82b762221f3f16d0 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
#define MAX 1100
void Sort(int x[],int n)
{
int i,j,min,t;
for(i=0;i<n-1;i++)
{
min = i;
for(j=i+1;j<n;j++)
{
if( x[min]>x[j] )
{
min = j;
}
}
if(min!=i)
{
t = x[min];
x[min] = x[i];
x[i] = t;
}
}
}
int Unfo(int x[],int n)
{
Sort(x,n);
if(x[0]>1)
return 1;
else
return -1;
}
main()
{
int i,n,x[MAX];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&x[i]);
printf("%d\n",Unfo(x,n));
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | d223218e221e35de0be9c7805729c6ac | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
int main()
{
int n;
int a[100000];
int kt = 0;
scanf("%d", &n);
for (int i=0; i<n; i++)
{
scanf("%d", &a[i]);
if (a[i] == 1) kt = 1;
}
int min = a[0];
if (kt == 1) printf("-1");
else printf("1");
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | b7a7469d79a29334f05e3fb450e09533 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
#include <conio.h>
#include <string.h>
#include <math.h>
int main()
{
long long int n,i,min=999999999,k=1;
scanf("%lld",&n);
for(i=1;i<=n;i++){
scanf("%lld",&k);
if(k<min){
min=k;
}
}
if(min==1){
printf("-1");
}
else{
printf("1");
}
return 0;
} | |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | ad340c8869ee5c5e9ac19c19cd178106 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main() {
int i,j;
int arr[1000];
scanf("%d",&i);
for(j=0;j<i;j++){
scanf("%d",arr+j);
//printf("%d\n",*(arr+j));
if(*(arr+j)==1){
printf("-1\n");
return 0;
}
}
printf("1\n");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 8a5b2386076ab4b655a6c01a786b55cb | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
long long int a[1000010],i,n,mark=1,flag=1;
int main()
{
scanf("%I64d", &n);
for(i=0;i<n;i++)
{
scanf("%I64d", &a[i]);
if(a[i]==1)
{
mark=-1;
}
}
if(mark==-1) printf("%I64d", mark);
else printf("%I64d", flag);
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 7231f3f0d3dc96db015fb850f9211a8d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
int GCD(int a,int b)
{
return b==0?a:GCD(b , a%b);
}
int min(int a, int b)
{
return a<b?a:b;
}
int main()
{
int n;
scanf ( "%d", &n );
int ans = 0;
int i;
int mi = 2100000000;
for(i=0; i<n; i++)
{
int x;
scanf ( "%d", &x );
ans = GCD(x, ans);
mi = min(mi, x);
}
if(mi==1)
printf ( "-1\n" );
else
printf ( "1\n" );
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | 82f4d0415dbc17bb2f7d1addaa8fcc2d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include <stdio.h>
main()
{
int n, a, i;
scanf("%d", &n);
for(i = 0; i< n; i++)
{
scanf("%d", &a);
if(a == 1)
{
printf("-1");
return 0;
}
}
printf("1");
return 0;
}
| |
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? | Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. | C | df94080c5b0b046af2397cafc02b5bdc | aaac169626e45619bbec922644b76b1d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"sortings"
] | 1437573600 | ["5\n1 2 3 4 5"] | null | PASSED | 1,000 | standard input | 2 seconds | The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. | ["-1"] | #include<stdio.h>
int main()
{
int n,a,m=1000000000;
scanf("%d",&n);
while(n--)
{
scanf("%d",&a);
if(m>a) m=a;
}
if(m==1) printf("-1\n");
else printf("1\n");
return 0;
} | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 570e344c38dd05a924a21fa68c8ea059 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{
long int n,k,i,q;
scanf("%ld %ld",&n,&k);
long int a[n];
for(i=0;i<n;i++)
scanf("%ld",&a[i]);
q=k;
i=1;
while(1)
{
if(q-i>0)
q=q-i;
else
break;
i++;
}
printf("%ld\n",a[q-1]);
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | bf1047f28d5a0fe5a888b4c79d900e00 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
int main()
{
int i, n, k, a[100005];
scanf("%d %d", &n, &k);
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (i = 1; i <= 2000000000; i++)
{
if (k - i > 0)k -= i;
else
{
printf("%d", a[k]);
break;
}
}
} | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 75aec045451f1a3d6ebf8e470a4fac7d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{
long long int n,k;
scanf("%lld%lld",&n,&k);
long long int i, a[n];
for(i=0;i<n;i++)
scanf("%lld",&a[i]);
// for(i=0;i<n;i++)
long long int j=0;
while(k-j>0)
{
k=k-j;
j++;
}
printf("%lld",a[k-1]);
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 9b5fe47e8f3bcf855d357801ee7cb822 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
int main()
{
long long int i, n, k;
while(scanf("%lld %lld", &n, &k) != EOF)
{
int ara[n];
for(i = 0; i < n; i++)
{
scanf("%d", &ara[i]);
}
long long int a = 1, pos;
long long int b1 = (-1 + (sqrt(1 + 4*2*k)))/2;
for(i = b1 - 1; a < k; i++)
{
a = (i + 1) * i / 2;
}
if(k == 1)
{
i = 0;
}
else
{
i -= 2;
}
pos = i - (a - k);
printf("%d\n",ara[pos]);
}
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 0a4f8ba03699d068b27dd38b0ba74358 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | x;main(k){scanf("%*d%d",&k);for(x=sqrt(2.0*k)-.5001,k-=x*(1ll+x)/2;k--;scanf("%d",&x));printf("%d",x);} | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | e92c47da651c62e6e7588585b0971b87 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<math.h>
int main()
{
long long int n,k,i,arr[100001],a=1,b=1,c;
scanf("%lld%lld",&n,&k);
for(i=0;i<n;i++)
{
scanf("%lld",&arr[i]);
}
c=2*k;
long long int d=(-b+sqrt(b*b+4*a*c))/2*a;
long long int e=k-((d*(d+1))/2);
if(e==0)
printf("%lld\n",arr[d-1]);
else
printf("%lld\n",arr[e-1]);
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | f16f1aae89e5b795a761d5adc567d806 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
int main() {
int n, k, i, id, x = 0;
scanf("%d%d", &n, &k);
for(i = 0; ; i++) {
if(x + i > k - 1) break;
else x += i;
}
for(i = 0; i < n; i++) {
scanf("%d", &id);
if(i == k - 1 - x) printf("%d\n", id);
}
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | b9e87e48a17e8c9c7a5f4bbb9bb60eab | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{
long int n,k,i,q;
scanf("%ld %ld",&n,&k);
long int a[n];
for(i=0;i<n;i++)
scanf("%ld",&a[i]);
q=k;
i=1;
while(1)
{
if(q-i>0)
q=q-i;
else
break;
i++;
}
printf("%ld\n",a[q-1]);
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 7610b6370cc90485b06a879614f4a8e8 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<string.h>
int main()
{
long long int n,m,i,d=0;
scanf("%lld %lld",&n,&m);
long long int ara[n];
for(i=0; i<n; i++)
{
scanf("%lld",&ara[i]);
}
for(i=1; i+1<=m; i++)
{
m=m-i;
//printf("%lld\n",m);
}
printf("%lld\n",ara[m-1]);
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 8e59add36d491342d460ce8c7b430161 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{
int n,k,a,c=0;
scanf("%d%d",&n,&k);
int arr[n];
for(int i=0;i<n;i++)
scanf("%d",&arr[i]);
for(int i=0;i<k;i++)
{
for(int j=0;j<=i;j++)
{
a=arr[j];
c++;
if(c==k)goto end;
}
}
end:
printf("%d",a);
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | e4955d1c58295c3ea681a310e72697f1 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
return ( *(long long*)a - *(long long*)b );
}
int main(void){
long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,x1,y1,k,sum2,min,f,r,o,sum1,sum=0,y,count1, a[1000000]={0};
scanf("%lld%lld",&n,&k);
for(i=1;i<=n;i++){
scanf("%lld",&a[i]);
if(k-i<=0){
printf("%lld",a[k]);
return 0;
}else{
k-=i;
}
}
return 0;
} | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 0745d09fcd75c818dc3fdb309b6d6888 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
return ( *(long long*)a - *(long long*)b );
}
int main(void){
long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a[1000000],count1=0,up,low,a2,b2;
scanf("%lld%lld",&n,&m);
count=0;
for(i=0;i<n;i++){
scanf("%lld",&a[i]);
}
i=1; // printf("%lld %lld\n",a[i],b[count-1]);
while(1){
if(m-i>0){
m-=i;
}else{
break;
}
i++;
}
printf("%lld",a[m-1]);
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 244efa26871704a3d96f9d51aef29a28 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<math.h>
main()
{
long long n, k, i, s, x, a[100010];
scanf("%lld%lld", &n, &k);
for (i=1; i<=n; i++)
{
scanf("%lld", &a[i]);
}
s=sqrt((8*k)+1);
s=s-1;
s=s/2;
x=s;
s=(s*(s+1))/2;
x=(x*(x-1))/2;
if (k!=s)
k=k-s;
else
k=k-x;
printf("%lld\n", a[k]);
return 0;
} | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifier of the first robot, then says the identifier of the second robot and after that says his own. This process continues from left to right until the n-th robot says his identifier.Your task is to determine the k-th identifier to be pronounced. | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 0fd3598aaff96b724892b7149ada46d3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{long long int n,k,i,j,c;
scanf("%I64d %I64d",&n,&k);
long long int a[n];
for(i=0;i<n;i++)
{scanf("%I64d",&a[i]);}
for(i=1;i<=n;i++)
{
if(2*k<(i*(i+1)))
{
j=k-i*(i-1)/2;
if(j%n==0)
printf("%I64d",a[j%n]);
else
printf("%I64d",a[j%n-1]);
break;
}
else if(2*k==(i*(i+1)))
{printf("%d",a[i-1]);
break;}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.