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
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
30304bf1051c5e81e910dd83086dc17d
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> int k; long long int n; int main() { scanf("%lld",&n); scanf("%d",&k); int no=n; int count=0; int temp=1; if(k>n||(k==1&&n!=1)) printf("-1"); else if(n==1) { printf("a"); } else if(n==2) printf("a...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
fe44bbf785951fbca7fea98f3a7d4d02
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> #include<string.h> #include<math.h> int main() { long int n,m,k,i,a[26]; char c; scanf("%d%d",&n,&k); a[0]=0; a[1]=0; for(i=0;i<k;i++) { a[i]=1; } if(k>n) printf("-1"); else if((n!=1) && (k==1)) printf("-1"); else { for(i=k;i<n;i++) { if((i-k)%2==0) a[0]++; else a[1]++; } while(a[1...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
fdcae086208e5603c410fccc21c5e7f1
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> int main() { int n,k; int i,j,ans=97; char a[1000010]; scanf("%d %d",&n,&k); if(n<k) { printf("-1\n"); return 0; } else if(k>26) { printf("-1\n"); return 0; } else if(k==1 && n==1) { // for(i=0;i<n;i++) // a[i]=ans; // a[n]='\0'; printf("a\n"); // return 0; } else if(k==1 ...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
e723aba3da03cb517bc79076959acbf5
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> #include<string.h> #include<stdlib.h> #define SORT(a,n) qsort(a,n,sizeof(int),intcmp) #define s(n) scanf("%d",&n) #define sc(n) scanf("%c",&n) #define sl(n) scanf("%I64d",&n) #define sf(n) scanf("%lf",&n) #define...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
2a4d53a48dc5b7aeeaa2fe84ea267348
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include <stdio.h> int main() { int n, k, i; char s[1000001]; scanf("%d %d", &n, &k); if (k > n || (k == 1 && n > 1)) { puts("-1"); return 0; } for (i = 0; i < n - k + 2; i++) s[i] = 'a' + i % 2; for (; i < n; i++) s[i] = 'a' + k - n + i; ...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
0a8199b6f31c3c46d9d8eb4b3843b8c9
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> int main() { int n,k,i; scanf("%d%d",&n,&k); if(n<k) { printf("-1"); return 0; } if(k==1) { if(n==1) printf("a"); else printf("-1"); return 0; } for(i=0;i<n-k+2;i++) { if(i&1) putchar('b'); else putchar('a'); } ...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
1cc3b5b57cdf421b57c0cac5f7415828
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> int main() { int n,k,i,j; scanf("%d%d",&n,&k); if(n<k)printf("-1\n"); else { if(k>26) { j=1; for(i=1; i<=n-24; i++) { if(i%2==1)printf("a"); if(i%2==0)printf("b"); } for(i=n-...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
8810bd137f05961460a7146e62e73497
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include <stdio.h> int main(void) { long int n,i,m,j; int k; char a[1000005]; scanf("%ld %d",&n,&k); if(n<k) printf("-1"); else if(k==1) { if(n>1) printf("-1"); else printf("a"); } else if(n==k) { for(i=0;i<n;i++) { ...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
d333e0cf2873e95aabb61802a3f3198f
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define max(a,b) a>=b?a:b #define min(a,b) a<b?a:b #define MOD 1000000007 int main(){ int n,m; scanf("%d%d",&n,&m); int b=m-2,a=n-b; char prev; if(n==m){ char j='a'; while(n){ printf("%c",j); ...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
228115460c9eee58149be11a4d4d6b87
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> main() { long int n,k,i,j=2; scanf("%ld %ld",&n,&k); if(k==1 && n>1) {printf("-1");exit(0);} if(k>n) printf("-1"); else { if(n==1) { printf("a");exit(0);} else {for(i=0;i<n-(k-2);i++) { if(i%2==0) printf("a"); ...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
a7bab928b48c87e0b63546ada44a5e8a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include <stdio.h> int main() { int i, n, k; scanf("%d%d", &n, &k); if (n < k) puts("-1"); else if (k == 1 && n != 1) puts("-1"); else if (k == 1 && n == 1) puts("a"); else { for (i = 0; i < n - k + 2; ++i) putchar(i & 1 ? 'b' : 'a'); for (i = 2; i < k; ++i) putchar('c' + i - 2); putchar('\n');...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
a048abe69107ec1f3503f566c5e8f7bd
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> #include<string.h> int main() { // freopen("as.txt","r",stdin); // freopen("Out.txt","w",stdout); int n,k; scanf("%d %d",&n,&k); if( (k==1 && n != 1) || k>n) { printf("-1\n"); } else { int i; char a[n]; for(i=0;i<n;i++) { ...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
2da241ccb8b6c525e1feae5c9f1521bf
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> #include<stdlib.h> int main() { char d; int n,k,a,b,c,sum=0; scanf("%d%d",&n,&k); if(n<k) printf("-1\n"); else { if(k>=2) { for(a=0;a<(n+2-k);a++) { d='a'+a%2; printf("%c",d); } for(;a<n;a++) { d='b'+(a+k-(n+1)); printf("%c",d); } printf("\n"); } el...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
0ce5f18e99ddbb402416f5862dadca7a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #define maxn 1000100 #define LL long long #define MIN(a,b) a >= b ? b : a #define MAX(a,b) a >= b ? a : b #define DEBUG(a) printf("debug:%d\n",a); #define INF 0x7fffffff char str[maxn]; int main() { #ifndef ONLINE_JUDGE freopen("dat...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
8d47bdb5f4abbb841337342664c3db82
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> #include<string.h> int main() { int n,k,i,it; scanf("%d%d",&n,&k); if ( n < k ) { printf("-1\n"); return 0; } char s[n+1]; char c; s[n] = '\0'; if (k == 1) { if (n == 1) { printf("a\n"); return 0; } else { printf("-1\n"); return 0; } } it = n - k + 2; for (i = 0; i < i...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
da1ec564aed55cb375b3ceb55deda3ce
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> main() { int i,n,k,j=0,l; scanf("%d%d",&n,&k); if(k>n||(k==1&&n>1)) printf("-1\n"); else{ if(n==1) printf("a\n"); else{ l=n-(k-2); for(i=0;i<l;i++) { printf("%c",j+97); j=!j; } j=2; for(i=0;i<k-2;i++,j++) printf("%c",j+97); printf("\n");} } return 0; }
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
5b49b1e114ef0a61ca7557091ef08fc4
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> char *arr="cdefghijklmnopqrstuvwxyz"; int main() { int i,N,K; scanf("%d %d",&N,&K); if(N<K || (N>1 && K==1)) {printf("-1");return 0;} if(K<=2) { for(i=0;i<N;i++) { if(i%2==0) printf("%c",'a'); else printf("%c",'b'); } ...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
1e821344e69cb0da987f9b3c16c873cd
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> int main() { int n,k,c,r,i; scanf("%d%d",&n,&k); if(k==n&&k<=26) { c='a'; for(i=0;i<k;i++) printf("%c",c+i); } else if(k>n||k==1) printf("-1"); else { for(i=0;i<n-(k-2);i++) { if(i%2==0) printf("a"); else printf("b"); } r=2;c='a'; for(i;i<n;i++,r++) printf("%c",c+r); } return 0; }
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
2706a38a1a738d96c33db7ac02fc9c99
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> #include<stdlib.h> int main() { long int i,j,k,l,m,n,p=2; char c,b,s[]="abcdefghijklmnopqrstuvwxyz"; l=0; scanf("%ld%ld",&n,&k); if(n<k) { printf("-1"); l=1; } if(n==1&&k==1) printf("a"); else if(n!=1&&k==1) printf("-1"); if(l!=1&&k!=1) { ...
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ...
In a single line print the required string. If there isn't such string, print "-1" (without the quotes).
C
2f659be28674a81f58f5c587b6a0f465
9e58848cabfac2279d39bf78a2b12957
GNU C
standard output
256 megabytes
train_003.jsonl
[ "constructive algorithms", "implementation" ]
1364916600
["7 4", "4 7"]
null
PASSED
1,300
standard input
2 seconds
A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.
["ababacd", "-1"]
#include<stdio.h> int main() { int num,k,i,j,c; scanf("%d%d",&num,&k); if(k>num) printf("-1\n"); else if(num==1&&k==1) printf("a\n"); else if(k==1) printf("-1\n"); else if(num==1) printf("a\n"); else { for(i=1;i<=num-k+2;i++) { if(i%2) printf("a"); else printf("b"); } c='c'; for(j=1;j<=k-2;j++) ...
There are $$$n$$$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). When a slime with a value $$$x$$$ eats a slime with a value $$$y$$$, the eaten slime di...
Print an only integer — the maximum possible value of the last slime.
C
090f57798ba45ba9e4c9d2d0514e478c
b0fd1f1ca16052e19ed34886f569bb64
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "implementation", "greedy" ]
1536248100
["4\n2 1 2 1", "5\n0 -1 -1 -1 -1"]
NoteIn the first example, a possible way of getting the last slime with value $$$4$$$ is: Second slime eats the third slime, the row now contains slimes $$$2, -1, 1$$$ Second slime eats the third slime, the row now contains slimes $$$2, -2$$$ First slime eats the second slime, the row now contains $$$4$$$ In the secon...
PASSED
1,800
standard input
2 seconds
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 500\,000$$$) denoting the number of slimes. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$-10^9 \le a_i \le 10^9$$$), where $$$a_i$$$ is the value of $$$i$$$-th slime.
["4", "4"]
#include<stdio.h> #include<math.h> #include<stdlib.h> int compare( const void* a, const void* b) { if( *(long long int*)a - *(long long int*)b < 0 ) return -1; if( *(long long int*)a - *(long long int*)b > 0 ) return 1; return 0; } int compare2( const void* a, const void* b) { if( ...
There are $$$n$$$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). When a slime with a value $$$x$$$ eats a slime with a value $$$y$$$, the eaten slime di...
Print an only integer — the maximum possible value of the last slime.
C
090f57798ba45ba9e4c9d2d0514e478c
86a745ac8d071105c735ab9b910646ac
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "implementation", "greedy" ]
1536248100
["4\n2 1 2 1", "5\n0 -1 -1 -1 -1"]
NoteIn the first example, a possible way of getting the last slime with value $$$4$$$ is: Second slime eats the third slime, the row now contains slimes $$$2, -1, 1$$$ Second slime eats the third slime, the row now contains slimes $$$2, -2$$$ First slime eats the second slime, the row now contains $$$4$$$ In the secon...
PASSED
1,800
standard input
2 seconds
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 500\,000$$$) denoting the number of slimes. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$-10^9 \le a_i \le 10^9$$$), where $$$a_i$$$ is the value of $$$i$$$-th slime.
["4", "4"]
#include<stdio.h> #include<math.h> #include<stdlib.h> #define N 500000 #define max(a,b)(a>b?a:b) long long a[N]; int main() { int i,n; int pos=0,net=0; scanf("%d",&n); long long sum=0; for(i=1;i<=n;i++) { scanf("%lld",&a[i]); sum+=abs(a[i]); if(a[i]>=0) pos++;...
There are $$$n$$$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). When a slime with a value $$$x$$$ eats a slime with a value $$$y$$$, the eaten slime di...
Print an only integer — the maximum possible value of the last slime.
C
090f57798ba45ba9e4c9d2d0514e478c
ad76d14b1bdb16b4803b7e3e362a3d04
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "implementation", "greedy" ]
1536248100
["4\n2 1 2 1", "5\n0 -1 -1 -1 -1"]
NoteIn the first example, a possible way of getting the last slime with value $$$4$$$ is: Second slime eats the third slime, the row now contains slimes $$$2, -1, 1$$$ Second slime eats the third slime, the row now contains slimes $$$2, -2$$$ First slime eats the second slime, the row now contains $$$4$$$ In the secon...
PASSED
1,800
standard input
2 seconds
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 500\,000$$$) denoting the number of slimes. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$-10^9 \le a_i \le 10^9$$$), where $$$a_i$$$ is the value of $$$i$$$-th slime.
["4", "4"]
#include <stdio.h> #include <math.h> #define MAX(a,b) (((a)>(b))?(a):(b)) #define MIN(a,b) (((a)<(b))?(a):(b)) int main() { long long int n,v,max=-10000000000,sum=0,min=10000000000,i; scanf("%lld",&n); if(n==1){ scanf("%lld",&v); printf("%lld",v); return 0; } else{ fo...
There are $$$n$$$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). When a slime with a value $$$x$$$ eats a slime with a value $$$y$$$, the eaten slime di...
Print an only integer — the maximum possible value of the last slime.
C
090f57798ba45ba9e4c9d2d0514e478c
88b1fbbf5251f8fbe2e2fe35a0da83a1
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "implementation", "greedy" ]
1536248100
["4\n2 1 2 1", "5\n0 -1 -1 -1 -1"]
NoteIn the first example, a possible way of getting the last slime with value $$$4$$$ is: Second slime eats the third slime, the row now contains slimes $$$2, -1, 1$$$ Second slime eats the third slime, the row now contains slimes $$$2, -2$$$ First slime eats the second slime, the row now contains $$$4$$$ In the secon...
PASSED
1,800
standard input
2 seconds
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 500\,000$$$) denoting the number of slimes. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$-10^9 \le a_i \le 10^9$$$), where $$$a_i$$$ is the value of $$$i$$$-th slime.
["4", "4"]
#include<stdio.h> #include<stdlib.h> #include<math.h> int main(){ int n,i,j=0,k; scanf("%d",&n); long long int ans=0, a[n],s=0,min; scanf("%I64d",&a[0]); min=abs(a[0]); s=abs(a[0]); if(n==1) {printf("%I64d",a[0]); return 0;} for(i=1;i<n;i++){ scanf("%I64d",&a[i]); s=s+abs(a[i]); if(abs(a[i])<min...
There are $$$n$$$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). When a slime with a value $$$x$$$ eats a slime with a value $$$y$$$, the eaten slime di...
Print an only integer — the maximum possible value of the last slime.
C
090f57798ba45ba9e4c9d2d0514e478c
3210049d474741471f4561403f934bf5
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "implementation", "greedy" ]
1536248100
["4\n2 1 2 1", "5\n0 -1 -1 -1 -1"]
NoteIn the first example, a possible way of getting the last slime with value $$$4$$$ is: Second slime eats the third slime, the row now contains slimes $$$2, -1, 1$$$ Second slime eats the third slime, the row now contains slimes $$$2, -2$$$ First slime eats the second slime, the row now contains $$$4$$$ In the secon...
PASSED
1,800
standard input
2 seconds
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 500\,000$$$) denoting the number of slimes. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$-10^9 \le a_i \le 10^9$$$), where $$$a_i$$$ is the value of $$$i$$$-th slime.
["4", "4"]
#include<stdio.h> #include<stdlib.h> #include<math.h> typedef long long int int64; #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define ABS(a) ((a)>(0)?(a):-(a)) void run(void){ int n; scanf("%d",&n); int *a=(int *)malloc(sizeof(int)*n); int i; for(i=0;i<n;i++) scanf("%d",a+i); i...
There are $$$n$$$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). When a slime with a value $$$x$$$ eats a slime with a value $$$y$$$, the eaten slime di...
Print an only integer — the maximum possible value of the last slime.
C
090f57798ba45ba9e4c9d2d0514e478c
fa6f7e34d5977f28def05e44c3788e42
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "implementation", "greedy" ]
1536248100
["4\n2 1 2 1", "5\n0 -1 -1 -1 -1"]
NoteIn the first example, a possible way of getting the last slime with value $$$4$$$ is: Second slime eats the third slime, the row now contains slimes $$$2, -1, 1$$$ Second slime eats the third slime, the row now contains slimes $$$2, -2$$$ First slime eats the second slime, the row now contains $$$4$$$ In the secon...
PASSED
1,800
standard input
2 seconds
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 500\,000$$$) denoting the number of slimes. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$-10^9 \le a_i \le 10^9$$$), where $$$a_i$$$ is the value of $$$i$$$-th slime.
["4", "4"]
#include <stdio.h> int main(){ int n; scanf("%d",&n); int en; if(n==1){ scanf("%d",&en); printf("%d\n",en); } else{ long long sum=0; int p,ne; p=ne=0; int mi=1000000000; while(n--){ scanf("%d",&en); if(en>0){ p=1; if(en<mi) mi=en; } else if(en<0){ en=-en; ne=1; ...
There are $$$n$$$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). When a slime with a value $$$x$$$ eats a slime with a value $$$y$$$, the eaten slime di...
Print an only integer — the maximum possible value of the last slime.
C
090f57798ba45ba9e4c9d2d0514e478c
2f59b89aeedf3e96913e2e0e52d37590
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "implementation", "greedy" ]
1536248100
["4\n2 1 2 1", "5\n0 -1 -1 -1 -1"]
NoteIn the first example, a possible way of getting the last slime with value $$$4$$$ is: Second slime eats the third slime, the row now contains slimes $$$2, -1, 1$$$ Second slime eats the third slime, the row now contains slimes $$$2, -2$$$ First slime eats the second slime, the row now contains $$$4$$$ In the secon...
PASSED
1,800
standard input
2 seconds
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 500\,000$$$) denoting the number of slimes. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$-10^9 \le a_i \le 10^9$$$), where $$$a_i$$$ is the value of $$$i$$$-th slime.
["4", "4"]
#include<stdio.h> long long f(long long x) { if(x>0)return x; return -x; } int main() { long long n,i; scanf("%lld",&n); long long a[n],sum=0,min,max=0; int zer=0,pos=0,neg=0; for(i=0;i<n;i++) { scanf("%lld",&a[i]); sum+=f(a[i]); if(a[i]==0)zer=1; else if(a[i]>0)pos=1; else neg=1; if(i==0) { ...
There are $$$n$$$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). When a slime with a value $$$x$$$ eats a slime with a value $$$y$$$, the eaten slime di...
Print an only integer — the maximum possible value of the last slime.
C
090f57798ba45ba9e4c9d2d0514e478c
3fe4139bb161ec1b5b8a1af1c7696338
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "implementation", "greedy" ]
1536248100
["4\n2 1 2 1", "5\n0 -1 -1 -1 -1"]
NoteIn the first example, a possible way of getting the last slime with value $$$4$$$ is: Second slime eats the third slime, the row now contains slimes $$$2, -1, 1$$$ Second slime eats the third slime, the row now contains slimes $$$2, -2$$$ First slime eats the second slime, the row now contains $$$4$$$ In the secon...
PASSED
1,800
standard input
2 seconds
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 500\,000$$$) denoting the number of slimes. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$-10^9 \le a_i \le 10^9$$$), where $$$a_i$$$ is the value of $$$i$$$-th slime.
["4", "4"]
#include <stdio.h> #include <limits.h> typedef long long ll; int main(){ ll n; scanf("%I64d",&n); ll arr[n]; ll ans=0; ll max=LLONG_MIN; ll min=LLONG_MAX; for(int i=0;i<n;i++){ scanf("%I64d",&arr[i]); if(arr[i]>max) max=arr[i]; if(arr[i]<min) min=arr[i]; } int hasseenmax=0; int hasse...
There are $$$n$$$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). When a slime with a value $$$x$$$ eats a slime with a value $$$y$$$, the eaten slime di...
Print an only integer — the maximum possible value of the last slime.
C
090f57798ba45ba9e4c9d2d0514e478c
11647fef9f62f95d7085a1beedea2100
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "dp", "implementation", "greedy" ]
1536248100
["4\n2 1 2 1", "5\n0 -1 -1 -1 -1"]
NoteIn the first example, a possible way of getting the last slime with value $$$4$$$ is: Second slime eats the third slime, the row now contains slimes $$$2, -1, 1$$$ Second slime eats the third slime, the row now contains slimes $$$2, -2$$$ First slime eats the second slime, the row now contains $$$4$$$ In the secon...
PASSED
1,800
standard input
2 seconds
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 500\,000$$$) denoting the number of slimes. The next line contains $$$n$$$ integers $$$a_i$$$ ($$$-10^9 \le a_i \le 10^9$$$), where $$$a_i$$$ is the value of $$$i$$$-th slime.
["4", "4"]
#include<stdio.h> #include<stdlib.h> int main() { long long T,i,temp,min,max,sum; scanf("%lld",&T); for(i=0,min=10000000000,max=-10000000000,sum=0;i<T;i++) { scanf("%lld",&temp); sum+=abs(temp); if(temp>max) max=temp; if(temp<min) min=temp; } ...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
ed1540b00867947b40673d8e514ff7da
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#include<stdio.h> int main() { int t; scanf("%d", &t); int n; int i, j; char s[200005]; int c[200005], cc; int ans; for (; t > 0; t--) { scanf("%d", &n); scanf("%s", s); cc = 1; c[0] = 1; for (i = 1; i < n; i++) { if (s[i] == s[i - 1]) c[cc - 1]++; else { c[cc] = 1; cc++; } ...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
615bfcbb5183d9ff84974cf4aa3fada7
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#include <stdio.h> int main() { int t; int n; char s[200005]; int c; int i; int f[200005]; int l; // len of frequency array int a, b; // two pointers, a from left, b from right int ans; scanf("%d", &t); while (t--) { scanf("%d\n", &n); gets(s); c = 1; l = 0; for (i=1; i<n; i+...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
93c95d15b75a5b0e7febc726d47dea87
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#include <stdio.h> char S[200003]; int C[200003]; int cC; int main() { int i; int T; int t; int n; int r; int temp; int R; scanf("%d", &T); while (T--) { scanf("%d", &n); scanf("%s", S + 1); temp = 1; cC = 0; for (i = 1; i <= n; i++) { while (S[i] == S[i + 1]) { temp++; i++; } ...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
90ba6f69065e36bcd980011775e93ea2
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#pragma region kyopuro_templates #pragma GCC optimize("Ofast") #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<stdbool.h> #include<assert.h> #include<time.h> #include<ctype.h> typedef long long ll; typedef long double ld; #define rep(i,l,r)for(ll i=(l);i<(r);i++) #define repp(i,l,r,k)f...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
2f638f6d54f36431013977d61c8b96f8
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <inttypes.h> #include <stdlib.h> #include <string.h> #include <math.h> typedef uint64_t uint64; typedef uint32_t uint32; typedef int64_t int64; typedef int32_t int32; #define finc(i,a,b) for(int32 i=(a);i<=(b);i++) #define fdec(i,a,b) for(int32 i=(b)+1;i-->...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
9ddedc6fd8da8dcaebed28c4d5a2a137
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#include <stdio.h> int main() { int t; scanf("%d", &t); for(int i = 0; i < t; i++) { int n; scanf("%d", &n); char s[200005]; int sl[n]; scanf("%s", s); if (n == 1 || n == 2) { printf("1\n"); continue; } sl[0] = 1; ...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
d005f29977d47282e6aee250b9c70423
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#include <ctype.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int t; int a[200100]; scanf("%d", &t); for (int m = 0; m < t; m++){ int n; scanf("%d ",&n); char temp; int p = 0,len=1; temp = getchar(); memset(a,...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
103defdcd4ccb85e332df395651d60cd
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#include <ctype.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int t; int a[200100]; scanf("%d", &t); for (int m = 0; m < t; m++){ int n; scanf("%d ",&n); char temp; int p = 0,len=1; temp = getchar(); memset(a,...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
65ccbf974aebdd4e3f592729e6ba03d2
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#include<stdio.h> int main(){int t,i,n,j,f,k,c,g[200005],sum; char s[200005]; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%d",&n); scanf(" %s",s); c=0; for(j=0;j<n;j++) { f=j; g[c]=0; while(s[f]==s[j]) { g[...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
26cedb9ca9a58a6abe57bdcd91848e08
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#include <stdio.h> char s[200005]; int d[200005]; int main() { int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); scanf("%s", s); int cnt = 0; d[cnt] = 1; for(int i = 1; i < n; i++) { if(s[i] == s[i-1]) d[cnt...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
9091fe2329d3a45404e5ac2f1e32bd79
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
// http://codeforces.com/contest/1430/submission/95393025 #include <stdio.h> int main() { int t; scanf("%d", &t); for(int ti = 0; ti < t; ti++) { int n; scanf("%d", &n); char s[200005]; int sl[200005]; scanf("%s", s); if (n == 1 || n == 2) { pr...
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1.You can perform operations on the string. Each operation consists of two steps: select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced by ...
For each test case, print a single integer — the maximum number of operations you can perform.
C
d0030996e6b29c8580463fae43bb04d4
f6a56bdf5a8affb898ddfc7373ebc6de
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "two pointers", "binary search", "greedy" ]
1602407100
["5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010"]
NoteIn the first test case, you can, for example, select $$$i = 2$$$ and get string 010 after the first operation. After that, you can select $$$i = 3$$$ and get string 1. Finally, you can only select $$$i = 1$$$ and get empty string.
PASSED
1,700
standard input
2 seconds
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line contains string $$$s$$$ of $$$n$$$ characters. Each character is e...
["3\n1\n1\n1\n3"]
#include<stdio.h> #include<stdlib.h> #include<math.h> int t, n; int i, j; int s[200001]; int len[200000], co, left; int ptr; int find(){ int i, thing = -1; for(i = 0; i < co; i++){ if(len[i] > 1) return i; else if(len[i] != -1) thing = i; } return thing; } int main(){ scanf("%d", &t); for(i = 0...
You have been given n distinct integers a1, a2, ..., an. You can remove at most k of them. Find the minimum modular m (m &gt; 0), so that for every pair of the remaining integers (ai, aj), the following unequality holds: .
Print a single positive integer — the minimum m.
C
656e44f1aa0202a3e8414bbce9381b09
9112549cbca2007dece10363fb8ab1cf
GNU C
standard output
256 megabytes
train_003.jsonl
[ "graphs", "number theory", "math" ]
1368363600
["7 0\n0 2 3 6 7 12 18", "7 1\n0 2 3 6 7 12 18"]
null
PASSED
2,400
standard input
2 seconds
The first line contains two integers n and k (1  ≤ n  ≤ 5000, 0 ≤ k ≤ 4), which we have mentioned above. The second line contains n distinct integers a1, a2, ..., an (0 ≤ ai ≤ 106).
["13", "7"]
#include<stdio.h> #include<time.h> #include<stdlib.h> #include<string.h> #include<math.h> #define max(a,b) ((a>b)?a:b) #define min(a,b) ((a>b)?b:a) #define UpFor(i,From,To) for(i=From;i<To;i++) #define DownFor(i,From,To) for(i=From;i>To;i--) #define LLg long long int N,M,k,MAX=0; int A[5001]; int hash[1000001],B[100000...
You have been given n distinct integers a1, a2, ..., an. You can remove at most k of them. Find the minimum modular m (m &gt; 0), so that for every pair of the remaining integers (ai, aj), the following unequality holds: .
Print a single positive integer — the minimum m.
C
656e44f1aa0202a3e8414bbce9381b09
190944cbffb7be3a07e8488f54cf848a
GNU C
standard output
256 megabytes
train_003.jsonl
[ "graphs", "number theory", "math" ]
1368363600
["7 0\n0 2 3 6 7 12 18", "7 1\n0 2 3 6 7 12 18"]
null
PASSED
2,400
standard input
2 seconds
The first line contains two integers n and k (1  ≤ n  ≤ 5000, 0 ≤ k ≤ 4), which we have mentioned above. The second line contains n distinct integers a1, a2, ..., an (0 ≤ ai ≤ 106).
["13", "7"]
#include <stdio.h> #include <string.h> #define N 5008 int a[N]; int b[1000008]; int delta[1000008]; int cmp(const void *p1, const void *p2) { return *(int *)p1 - *(int *)p2; } int main() { int n, k; scanf("%d%d", &n, &k); int i, j; for (i=0; i < n; i++) { scanf("%d", &a[i]); } qsort(a, n, sizeof(a[0]), cmp...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
dc7b11ff4b87cb2eeda6f96b6c41a508
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include <stdio.h> #include <math.h> int main () { int n, m,i; long long int ancho, altura, base; scanf("%d", &n); long long int stairs[n]; for (i=0; i<n; i++) scanf("%lld", &stairs[i]); scanf("%d", &m); long long int boxes[m][2]; for (i=0; i<m; i++) scanf("%lld %lld", ...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
6d6e5b532311d5d525ce8dfdddf96725
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> int main(void){ int n,i,m;//n:numero de escaleras, i:contador, m:numero de cuadros scanf("%d",&n); long long int escaleras[n]; for(i=0;i<n;i++){ scanf("%I64d",&escaleras[i]);//Cargamos el Valor de las alturas de las escaleras } scanf("%d",&m);//Introducimos el numeros d...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
673a17e2a1a885f7efea009ee975e177
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> typedef struct dato{ long long int W,H; }AN; int main(){ int n,i,j,Cu,ce=0; scanf("%d",&n); long long int Esc[n],base=0; for(i=0;i<n;i++){ scanf("%I64d",&Esc[i]); } scanf("%d",&Cu); AN Cuad[Cu]; for(i=0;i<Cu;i++){ scanf("%I64d %I64d",&Cuad[i].W,&Cuad...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
68e366bede2de1e411ffb229eb72c559
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <stdbool.h> void impr_mapa(int mapa[], int cant_columnas){ int cont_aux; printf("\n-------------------------------------------------------\n"); for(cont_aux=0;cont_aux<cant_columnas;cont_aux++) { printf("%d ",mapa[cont_...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
492ce76f4821ea8e624fae0fa8ae3a9a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> typedef struct box { long long int wi; long long int hi; } Box; typedef Box * Dima; int main () { Dima Dshand; int n,m,i=0; scanf("%d",&n); long long int stairs[n],stairheight,boxheight; for(i=0;i<n;i++) { scanf("%I64D",&stairs[i]); } scanf("%d",&m); ...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
bcfcb71050d35453a27781467b94ca7e
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> int main(){ long long int n,i,can_box,wi,hi,x; long long int max = 0; scanf("%I64d",&n); long long int stairs[n]; for(i = 0 ; i < n ;i++){ scanf("%I64d",&stairs[i]); } max = stairs[0]; scanf("%I64d",&can_box); long long int j = 0; long long int order_box[can_box]; x = 0; for(i = 0; i <...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
73f32379fea8fd330e0b0c612cd36802
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include <stdio.h> #include <stdlib.h> typedef struct { long long int anchura; long long int altura; }Dimensiones; int main(){ int i,n; scanf("%d", &n); long long int alturas[n];/*CREAMOS EL VECTOR QUE GUARDARA LAS ALTURAS DE LOS STAIRS*/ for(i = 0; i < n; i++){ scanf("%I64d", &alturas[i]); } int ...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
1123fcf74aa17a728444775ff2bab50a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> int main(void) { unsigned long long int n,i,m,newHeight,w,j,MaxH,MaxN=0; scanf("%I64d",&n); unsigned long long int st[n]; for(i=0;i<n;i++) { scanf("%I64d", &st[i]); } if(n>0) { MaxH=st[0]; } scanf("%I64d",&m); unsigned long long int boxHeig...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
57ac5ddb0534f497012e6a4df30b4a71
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> unsigned long long int V[1000000]; unsigned long long int N,h,R; unsigned long long int i,m,w,h1; unsigned long long int max(long long int num1,long long int num2) { unsigned long long int result; if (num1 > num2) result = num1; else result = num2; return result; } int main(...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
c5568683f3c8c2394965ca4eb0107085
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include <stdio.h> #include <stdlib.h> typedef struct { long long int large; long long int alto; }CAJA; int main ( ) { int n ,m, i; scanf ("%d", &n); long long int escalera [n]; for (i=0; i<n; i++) { scanf("%I64d", &escalera[i]); } scanf ("%d", &m); CAJA caja [m]; for (i=0; i<m; i++) { scanf("%I64...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
7605c8455ea9979fc55bda2e12814492
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include <stdio.h> #include <stdlib.h> int lugares(int fila, int columna, long long int *mat); void ubicar(int col, int val, long long int *vec); typedef struct { long long int wid; long long int hei; }DATO; int main(){ int n; int i, j; scanf("%d", &n); long long int a[n];/*CREAMOS EL VECTOR ...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
95b3b8201fec1a1f9f3a35f31987c00f
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> typedef struct{ long long int l; long long int a; }dimc; int main(){ int n,i,c; scanf("%d",&n); long long int esc[n]; for(i=0;i<n;i++){ scanf("%I64d",&esc[i]); } scanf("%d",&c); dimc caja[c]; for(i=0;i<c;i++){ scanf("%I64d",&caja[i].l); ...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
28c5b518cfbd41e22fb67bb7f5048a0f
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> int main(void){ int n,i,m;//n:numero de escaleras, i:contador, m:numero de cuadros scanf("%d",&n); long long int escaleras[n]; for(i=0;i<n;i++){ scanf("%I64d",&escaleras[i]);//Cargamos el Valor de las alturas de las escaleras } scanf("%d",&m);//Introducimos el numeros d...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
0ef1a5ac3bb5cfd97e22ccc893180c09
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> int main(void){ int n,i,m;//n:numero de escaleras, i:contador, m:numero de cuadros scanf("%d",&n); long long int escaleras[n]; for(i=0;i<n;i++){ scanf("%I64d",&escaleras[i]);//Cargamos el Valor de las alturas de las escaleras } scanf("%d",&m);//Introducimos el numeros d...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
f1030cd478abc49331f8cb8497d06708
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include <stdio.h> int main() { int n, m, i, w, h; double max = 0; scanf("%d", &n); int v[n]; for(i=0; i<n; i++) scanf("%d", &v[i]); scanf("%d", &m); for(i=0; i<m; i++) { scanf("%d %d", &w, &h); if (max > v[w-1]) { max = max; } else { ma...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
2b17fc7f7f405771e92b959a5ec930ca
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> typedef long long ll; ll max(ll a,ll b){ return (a>b)?a:b;} int main() { ll n; scanf("%lld",&n); ll i,j,w,m,h,x,A[n]; for(i=0;i<n;++i) scanf("%lld",&A[i]); scanf("%lld",&m); ll ans=0,prev=0; for(i=0;i<m;++i) { scanf("%lld%lld",&w,&h); ans=max(ans+prev,A[w-1]);prev=h; printf("%lld\n",ans);} retur...
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each ...
Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d...
C
fb0e6a573daa0ee7c20d20b0d2b83756
6bd9cf8a66324af958d91c68ad8f14bb
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "data structures", "implementation" ]
1360769400
["5\n1 2 3 6 6\n4\n1 1\n3 1\n1 1\n4 3", "3\n1 2 3\n2\n1 1\n3 1", "1\n1\n5\n1 2\n1 10\n1 10\n1 10\n1 10"]
NoteThe first sample are shown on the picture.
PASSED
1,500
standard input
2 seconds
The first line contains integer n (1 ≤ n ≤ 105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1, a2, ..., an (1 ≤ ai ≤ 109; ai ≤ ai + 1). The next line contains integer m (1 ≤ m ≤ 105) — the number of boxes. Each of the following m lines contains...
["1\n3\n4\n6", "1\n3", "1\n3\n13\n23\n33"]
#include<stdio.h> unsigned long long int V[1000000]; unsigned long long int N,h,R; unsigned long long int i,m,w,h1; unsigned long long int max(long long int num1,long long int num2) { unsigned long long int result; if (num1 > num2) result = num1; else result = num2; return result; } int main(...
A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an...
Print the maximally possible width of a coffin with absolute or relative error no more than 10 - 7. If a coffin with the given length and positive width (the coffin that would meet the conditions from the problem's statement) does not exist, print "My poor head =(" (without quotes). It is guaranteed that if the answer ...
C
c4b0f9263e18aac26124829cf3d880b6
037d77a8d081b3e4d384594e07c42154
GNU C
standard output
256 megabytes
train_003.jsonl
[ "geometry", "ternary search" ]
1311346800
["2 2 1", "2 2 2", "2 2 3", "2 2 6"]
NoteIn the first example the answer is restricted by the coffin's length (remember — coffin's widths should not be larger than it's length).In the second example it is possible to drag the coffin through the corridor thanks to rotating wheels: firstly, drag it forward by one side while it will not be hampered by the wa...
PASSED
2,500
standard input
2 seconds
The first line contains three space-separated integers a, b and l from the problem's statement (1 ≤ a, b, l ≤ 104).
["1.0000000", "2.0000000", "1.3284271", "My poor head =("]
#include <stdio.h> #include <math.h> int a,b,l; double f(double x){return cos(x)*(b*tan(x)+a-l*sin(x));} main(i){ double w,S=0,T=acos(0),s,t; scanf("%d%d%d",&a,&b,&l); if(a>b) a^=b^=a^=b; if(l<=b) w=l<=a?l:a; else for(i=255;i--;(w=f(s))>f(t)?S=s:(T=t)) s=(S*2+T)/3,t=(S+T*2)/3; printf(w>1e-7?...
A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an...
Print the maximally possible width of a coffin with absolute or relative error no more than 10 - 7. If a coffin with the given length and positive width (the coffin that would meet the conditions from the problem's statement) does not exist, print "My poor head =(" (without quotes). It is guaranteed that if the answer ...
C
c4b0f9263e18aac26124829cf3d880b6
7e88049b44e5feb5182bae5c1ce28a08
GNU C
standard output
256 megabytes
train_003.jsonl
[ "geometry", "ternary search" ]
1311346800
["2 2 1", "2 2 2", "2 2 3", "2 2 6"]
NoteIn the first example the answer is restricted by the coffin's length (remember — coffin's widths should not be larger than it's length).In the second example it is possible to drag the coffin through the corridor thanks to rotating wheels: firstly, drag it forward by one side while it will not be hampered by the wa...
PASSED
2,500
standard input
2 seconds
The first line contains three space-separated integers a, b and l from the problem's statement (1 ≤ a, b, l ≤ 104).
["1.0000000", "2.0000000", "1.3284271", "My poor head =("]
#include <stdio.h> #include <math.h> int a,b,l; double f(double x){return cos(x)*(b*tan(x)+a-l*sin(x));} main(i){ double w,S=0,T=acos(0),s,t; scanf("%d%d%d",&a,&b,&l); if(a>b) a^=b^=a^=b; if(l<=b) w=l<=a?l:a; else for(i=255;i--;(w=f(s))>f(t)?S=s:(T=t)) s=(S*2+T)/3,t=(S+T*2)/3; printf(w>1e-7?...
A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an...
Print the maximally possible width of a coffin with absolute or relative error no more than 10 - 7. If a coffin with the given length and positive width (the coffin that would meet the conditions from the problem's statement) does not exist, print "My poor head =(" (without quotes). It is guaranteed that if the answer ...
C
c4b0f9263e18aac26124829cf3d880b6
192dec7514795c774a7a4d5ed5b12db8
GNU C
standard output
256 megabytes
train_003.jsonl
[ "geometry", "ternary search" ]
1311346800
["2 2 1", "2 2 2", "2 2 3", "2 2 6"]
NoteIn the first example the answer is restricted by the coffin's length (remember — coffin's widths should not be larger than it's length).In the second example it is possible to drag the coffin through the corridor thanks to rotating wheels: firstly, drag it forward by one side while it will not be hampered by the wa...
PASSED
2,500
standard input
2 seconds
The first line contains three space-separated integers a, b and l from the problem's statement (1 ≤ a, b, l ≤ 104).
["1.0000000", "2.0000000", "1.3284271", "My poor head =("]
#include <stdio.h> #include <math.h> int a,b,l; double f(double x){return cos(x)*(b*tan(x)+a-l*sin(x));} main(i){ double w,S=0,T=acos(0),s,t; scanf("%d%d%d",&a,&b,&l); if(a>b) a^=b^=a^=b; if(l<=b) w=l<=a?l:a; else for(i=255;i--;(w=f(s))>f(t)?S=s:(T=t)) s=(S*2+T)/3,t=(S+T*2)/3; printf(w>1e-7?...
A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an...
Print the maximally possible width of a coffin with absolute or relative error no more than 10 - 7. If a coffin with the given length and positive width (the coffin that would meet the conditions from the problem's statement) does not exist, print "My poor head =(" (without quotes). It is guaranteed that if the answer ...
C
c4b0f9263e18aac26124829cf3d880b6
f749ca4833d63b9e4d59434a50b7b195
GNU C
standard output
256 megabytes
train_003.jsonl
[ "geometry", "ternary search" ]
1311346800
["2 2 1", "2 2 2", "2 2 3", "2 2 6"]
NoteIn the first example the answer is restricted by the coffin's length (remember — coffin's widths should not be larger than it's length).In the second example it is possible to drag the coffin through the corridor thanks to rotating wheels: firstly, drag it forward by one side while it will not be hampered by the wa...
PASSED
2,500
standard input
2 seconds
The first line contains three space-separated integers a, b and l from the problem's statement (1 ≤ a, b, l ≤ 104).
["1.0000000", "2.0000000", "1.3284271", "My poor head =("]
#include <stdio.h> #include <math.h> int a,b,l; double f(double x){return cos(x)*(b*tan(x)+a-l*sin(x));} main(i){ double w,S=0,T=acos(0),s,t; scanf("%d%d%d",&a,&b,&l); if(a>b) a^=b^=a^=b; if(l<=b) w=l<=a?l:a; else for(i=255;i--;(w=f(s))>f(t)?S=s:(T=t)) s=(S*2+T)/3,t=(S+T*2)/3; printf(w>1e-7?...
A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an...
Print the maximally possible width of a coffin with absolute or relative error no more than 10 - 7. If a coffin with the given length and positive width (the coffin that would meet the conditions from the problem's statement) does not exist, print "My poor head =(" (without quotes). It is guaranteed that if the answer ...
C
c4b0f9263e18aac26124829cf3d880b6
3e4971703bfa7eb8096ac54cabb21e4f
GNU C
standard output
256 megabytes
train_003.jsonl
[ "geometry", "ternary search" ]
1311346800
["2 2 1", "2 2 2", "2 2 3", "2 2 6"]
NoteIn the first example the answer is restricted by the coffin's length (remember — coffin's widths should not be larger than it's length).In the second example it is possible to drag the coffin through the corridor thanks to rotating wheels: firstly, drag it forward by one side while it will not be hampered by the wa...
PASSED
2,500
standard input
2 seconds
The first line contains three space-separated integers a, b and l from the problem's statement (1 ≤ a, b, l ≤ 104).
["1.0000000", "2.0000000", "1.3284271", "My poor head =("]
#include <stdio.h> #include <math.h> int a,b,l; double f(double x){return cos(x)*(b*tan(x)+a-l*sin(x));} main(i){ double w,S=0,T=acos(0),s,t; scanf("%d%d%d",&a,&b,&l); if(a>b) a^=b^=a^=b; if(l<=b) w=l<=a?l:a; else for(i=100;i--;(w=f(s))>f(t)?S=s:(T=t)) s=(S*2+T)/3,t=(S+T*2)/3; printf(w>1e-7...
A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an...
Print the maximally possible width of a coffin with absolute or relative error no more than 10 - 7. If a coffin with the given length and positive width (the coffin that would meet the conditions from the problem's statement) does not exist, print "My poor head =(" (without quotes). It is guaranteed that if the answer ...
C
c4b0f9263e18aac26124829cf3d880b6
44d43ec405e17239d28c1a8ab8cf5e49
GNU C
standard output
256 megabytes
train_003.jsonl
[ "geometry", "ternary search" ]
1311346800
["2 2 1", "2 2 2", "2 2 3", "2 2 6"]
NoteIn the first example the answer is restricted by the coffin's length (remember — coffin's widths should not be larger than it's length).In the second example it is possible to drag the coffin through the corridor thanks to rotating wheels: firstly, drag it forward by one side while it will not be hampered by the wa...
PASSED
2,500
standard input
2 seconds
The first line contains three space-separated integers a, b and l from the problem's statement (1 ≤ a, b, l ≤ 104).
["1.0000000", "2.0000000", "1.3284271", "My poor head =("]
#include <stdio.h> #include <math.h> int a,b,l; double f(double x){return cos(x)*(b*tan(x)+a-l*sin(x));} main(i){ double w,S=0,T=acos(0),s,t; scanf("%d%d%d",&a,&b,&l); if(a>b) a^=b^=a^=b; if(l<=b) w=l<=a?l:a; else for(i=100;i--;(w=f(s))>f(t)?S=s:(T=t)) ...
A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an...
Print the maximally possible width of a coffin with absolute or relative error no more than 10 - 7. If a coffin with the given length and positive width (the coffin that would meet the conditions from the problem's statement) does not exist, print "My poor head =(" (without quotes). It is guaranteed that if the answer ...
C
c4b0f9263e18aac26124829cf3d880b6
88b3165b1687405336aee4fcf4f46ef2
GNU C
standard output
256 megabytes
train_003.jsonl
[ "geometry", "ternary search" ]
1311346800
["2 2 1", "2 2 2", "2 2 3", "2 2 6"]
NoteIn the first example the answer is restricted by the coffin's length (remember — coffin's widths should not be larger than it's length).In the second example it is possible to drag the coffin through the corridor thanks to rotating wheels: firstly, drag it forward by one side while it will not be hampered by the wa...
PASSED
2,500
standard input
2 seconds
The first line contains three space-separated integers a, b and l from the problem's statement (1 ≤ a, b, l ≤ 104).
["1.0000000", "2.0000000", "1.3284271", "My poor head =("]
#include <stdio.h> #include <math.h> int a,b,l; double f(double x){return cos(x)*(b*tan(x)+a-l*sin(x));} main(i){ double w,S=0,T=acos(0),s,t; scanf("%d%d%d",&a,&b,&l); if(a>b) a^=b^=a^=b; if(l<=b) w=l<=a?l:a; else for(i=255;i--;(w=f(s))>f(t)?S=s:(T=t)) s=(S*2+T)/3,t=(S+T*2)/3; printf(w>1e-7?...
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 &lt; i2 &lt; ... &lt; ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 &amp; ai2 &amp; ... &amp; aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). O...
Output a single integer representing the number of required groups modulo 1000000007 (109 + 7).
C
0c5bc07dec8d8e0201695ad3edc05877
db327e639e7bfd473e53bf68bfebf082
GNU C
standard output
256 megabytes
train_003.jsonl
[ "dp", "combinatorics", "bitmasks" ]
1405774800
["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1"]
null
PASSED
2,400
standard input
2 seconds
The first line contains a single integer n (1 ≤ n ≤ 106). The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 106).
["0", "10", "53"]
#include <stdio.h> #include <string.h> #include <stdbool.h> #define MAX 1048576 #define MOD 1000000007 #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) int n, ar[MAX], P[MAX], dp[MAX][2]; int Solve(){ int i, j, k, x, y, u, v, bitmask; clr(dp); for (i = 0; i < n; i+...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
a1ddb3bca518a8fc2592fe04abfbc8da
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> int min(int a,int b) { if(a==0) return b; else if(b==0) return a; else if(a>b) return b; else return a; } int func(int n,int sum,int po3) { if(sum>=n) return sum; if(po3>=100000) return 0; else return min(func(n,sum+po3,po3*3),func(n,sum,po3*3)); } int main(void) { in...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
3f4670c71a180a988140ea74532d2528
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <math.h> int main() { long long int ans,no[500],pp; int num,pwr,arr[100]; scanf("%d",&num); for (int i = 0; i < 100; i++) arr[i] = i; for (int i = 0; i < num; i++) scanf("%lld",&no[i]); for (int i = 0; i < num; i++) { pwr = (int) (log(no[i])/log(3)); ans = (long long int)(pow(3...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
1c2db3cd549154b15e74af856b87a79c
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <math.h> int power ( int x ); int solve (int n); void reset(); int calculate (); int a[10],b[10]; int main() { int n , q ; short i; for ( i = 0 ; i < 10 ; i++ ) { a[i] = power(i); } scanf ("%i",&q); for ( i = 0 ; i < q ; i++ ) { reset(); ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
7495b476dfeb56ef73b523689f7fe739
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> int goodnumber(int v,int arr[]); void main() { int i,j,k,x,p,queries,q[500],bin_ter[700]; char buffer[100]; for(i=0;i<700;i++) { itoa(i,buffer,2); x=strlen(buffer); p=0; k=x-1; j=0; ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
8fb14028089f7976b238ca6fb385390b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include<stdio.h> int main() { int q; scanf("%d", &q); int i, j; long long int n, m, k; long long int p[100], l; for (j = 0; j < q; j++) { scanf("%lld", &n); l = 0; while (n > 0) { p[l] = n % 3; n /= 3; l++; } p[l] = 0; k = -1; for (i = l - 1; i >= 0; i--) { if (p[i] > 1) { k...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
15d265012679d2b3d534963728298cd4
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <math.h> int main() { long long int ans,no[500],pp; int num,pwr,arr[100]; scanf("%d",&num); for (int i = 0; i < 100; i++) arr[i] = i; for (int i = 0; i < num; i++) scanf("%lld",&no[i]); for (int i = 0; i < num; i++) { pwr = (int) (log(no[i])/log(3)); ans = (long long int)(pow(3...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
f554523ae5545663b5e254b5d684bb78
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> int goodnum(int n) { int i,rem,num=n; while(n!=0) { rem=n%3; if(rem==2) { num=goodnum(num+1); return num; } else { n=n/3; } } return num; } int main() { int q,i,n; scanf("%d",&q);...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
22c12e1a02b30121372608ab20ebbf40
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> //#include <math.h> #include <string.h> int b3[40]; long long int pow3(int y){ long long res = 1; for(int i = 1; i <= y; ++i) res *= 3; return res; } long long int base3(long long int x){ int maiorov = 0; long long p3; for(int i = 39; i >= 0; --i){ p3 = pow3(i); b3[i] = x/p3; x %= p3; ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
cd64fad012c570764820b26d73fc1fb8
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> long long BP(long long a, long long b) { long long r = 1; while (b) { if (b & 1) { r *= a; } a *= a; b >>= 1; } return r; } int main() { int Q; int n; int t; int tS; int temp; int R; scanf("%d", &Q); while (Q--) { scanf("%d", &n); tS = 0; for (t = 16; t >= 0; t--) {...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
39383521925e5066d69a7c527a9f45a9
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include<stdio.h> int main() { int q,n; int ar[520]; int f1=0,f2=0,f3=0,f4=0,f5=0,f6=0; scanf("%d", &q); ar[0]=1; int c=1; int a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0,a9=0,a10=0; for(int i=0;i<=512;i++) { a1=a1^1; if(c%2==0) a2=a2^1; if(c%4==0) a3=a3^1; if(c%8==0) a4=a4^1; if(c%16==0) a5...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
42bcb0777c1312fc57301e09bf7510f8
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> int main(void) { int t,k,i,d,j; scanf("%d",&t); for(k=0;k<t;k++) { int n; scanf("%d",&n); if(n==1) printf("1\n"); d=n; while(d!=1) { if(d%3==0) { d=d/3; if(d==1) { printf("%d\n",n); break; ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
9b6c2ef1952368a13dba3aa8dc21e5c9
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include<math.h> int main(void) { int q; scanf("%d\n",&q); while(q--){ int n; scanf("%d\n",&n); int j; for(j=0;(pow(3,j)-1)/2<n;j++){ } int s; s=(pow(3,j)-1)/2; int p=j-2; while(p+1){ if(s-pow(3,p)>=n){ s-=pow(3,p); } p--; } printf("%d\n",s); } re...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
36180b6fee327ea41ac40ab32bba7cc1
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { long long int n,p=3,k=1; scanf("%lld",&n); while(k<n) { k+=p; p=p*3; } while(p) { if(k-p>=n) k-=p; p/=3; } ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
9f02d069e0fdae62b7586ebb2cfebf57
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
/* AUTHOR:AKASH JAIN * USERNAME:akash19jain * DATE:22/10/2019 */ // #include<algorithm> // #include <bits/stdc++.h> // using namespace std; #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<stdbool.h> #include<ctype.h> #define SC1(x) scanf("%lld",&x) #define SC2(x,y)...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
a8778e922c428ff77b3c2da6669fcecc
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include<stdio.h> int main(){ int q,n,a,sum,product,i,product_use,j,result[500]; scanf("%d",&q); for(i=0;i<q;i++){ result[i]=0; sum=0; scanf("%d",&n); product=1; a=0; while(n>product){ product=product*3; a=a+1; } product_use=product; for(j=0;j<=a;j++){ ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
a91510ea9bbf8da4a12d08eaca7f9d8e
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> int main() { int q; int i, j; int k; int x; int t; scanf("%d", &q); for (i = 0; i < q; i++) { scanf("%d", &x); for (j = x;; j++) { if (j % 3 == 0) { k = j; while (k % 3 == 0) { k = k / 3; if (k == 0) break; } if (k == 1) break; } if (j % 3 ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
9fc1f9553fc2c244a01c5a69ca16ca6a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <stdlib.h> #include <math.h> int main(){ int a[10],i; for(i=0;i<10;i++){ a[i] = pow(3,i); } int t,n; scanf("%d" , &t); while(t--){ scanf("%d" , &n); int s=n,flag=0; while(s!=0){ i=9; while(i>=0){ if(a[i]<=s){ s=s-a[i]; if(s==0){ flag=1; break; ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
a38dbe3edab7e61934a9d6e547aabc10
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include<stdio.h> int main() { int p; scanf("%d", &p); for (int u = 1; u <= p; u++) { int n; scanf("%d", &n); for (int i = n;;i++) { int m = i; int t = i; int num = i; int time ; if (i % 3 == 2) { continue; } for (int j = 1; j <= 10; j++) { m = m / 3; if (m == 0) { ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
ddf0e199034988f8f1d5b03d4ae88d4a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include<stdio.h> #include<math.h> int m[10011100]; int main() { int p; scanf("%d",&p); while(p--) { long long n,x=0,i,j,k,l=0,sum=0,sum1=0,s=0; int f=0; scanf("%lld",&n); while(n) { k=n%3; m[l++]=k; n=n/3; } for...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
df1b8eee41f3fb0ffb9fdb018ff3566d
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <math.h> int main() { int q,l; scanf("%d",&q); for(l=1;l<=q;l++){ int f=0,ans=0,n,i,j=9999,s=0,ps=0,diff,pss=0; scanf("%d",&n); diff=n; for(i=0;i<j-1;i++){ //printf("Dhukse "); s=pow(3,i); if(s==diff){ans=ans+s;printf("%d\n",pss+diff);f=1;bre...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
75c0908dd33c602d78bc86e7ca92cd5b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <stdbool.h> int is_good(int n){ while (n > 0){ if (n % 3 == 2) return false; n /= 3; } return true; } int main(void){ int q; scanf("%d", &q); int n; for (int i = 0; i < q; i++){ scanf("%d", &n); while (true){ if (is_good(n)){ printf("%d\n", n); break; } n++...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
10763a107386b29f5b8f57964539625a
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
/* 问题描述:给出Q组查询,每组给出一个N找到一个大于等于n的m, m可以分解成不同的3的幂次相加。 解决方案:三进制思想,把数化为三进制数,如果所有数字都不是2就可以 他要取最小的大于给定的数的好数,只要把最高位的2后面的一个0改为1, 前面的所有数改为0,转化成10进制输出和。 */ #include<stdio.h> #include<math.h> #include<string.h> #pragma warning (disable:4996) //#define fIO #ifdef fIO #pragma warning (disable:6031) #endif long long my_pow(l...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
ba4d8bbd9faac2550c5080ed98455d92
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <string.h> long long solve(long long n) { static int aa[50]; int cnt, i, j; long long n_; memset(aa, 0, sizeof aa); cnt = 0; while (n > 0) { aa[cnt++] = n % 3; n /= 3; } i = cnt - 1; while (i >= 0 && aa[i] != 2) i--; if (i >= 0) { for (j = 0; j <= i; j++) aa[j] = 0; ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
317b344e20e8e7788aff4225537c2fd9
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <stdlib.h> #include <math.h> /// func min to check a,b int min (int a , int b) { if (a>b) return b; else return a; } int main () { int q , n , ct=0,sum,i,j=0,t,o,ck,k=0,temp ; scanf("%d" , &q); t = q; int arr[t]; while ( q > 0 ) { sum = 0; ct = 0; scanf ("%d" , &n); w...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
1eb42d0bbc014b78316d8ff85cf2c487
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int t; scanf("%d",&t); for(int i=0;i<t;i++) { int n; scanf("%d",&n); int a[10]={0}; int b=0; while(n>0) { a[b++]=n%3; n/=3; } int count=-1; x:{}; for(int i=b;i>=0;i--) { if(a[i]==2) { a[i+1]+...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
14fa5df39818be7c5115e160f7bebedc
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <math.h> int main(void) { int q, reverse_3[50]; long long n, answer; scanf("%d", &q); for (int i = 0; i < q; i++) { answer = 0; for (int j = 0; j < 50; j++) reverse_3[j] = 0; scanf("%lld", &n); for (long long k = n, j = 0; k != 0; k /= 3, j++) { reverse_3[j] = k % 3; ...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
b80008d4bc044076f1f67448390dd7a9
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
/* https://codeforces.com/contest/1249/submission/63236039 (Dukkha) */ #include <stdio.h> #include <string.h> int main() { int q; scanf("%d", &q); while (q--) { static int aa[40]; long long n; int k, i; scanf("%lld", &n); k = 0; while (n > 0) { aa[k++] = n % 3; n /= 3; } for (i = k - 1; i >=...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
8ea950d702f2c18c5b7d8e8f3471d53f
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include<stdio.h> int good(int n,int m,int count) { int r; r=n%3; if (n==0) return m; else if (r==0) return good(n/3,m,count); else if (r==1) { count++; return good(((n-1)/3),m,count); } else if(count>1 || r==2) return good(m+1,m+1,0); } int main (void) { int q; scanf("%d",&q); int ans[q]; f...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
07133034341b01844b0309bfa6b7183b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <stdlib.h> #include <math.h> int min (int a , int b) { if (a>b) return b; else return a; } int main () { int q , n , count = 0 , sum , i , j = 0 , t , t1 , t2 , o , res , k = 0 , temp ; scanf("%d" , &q); t = q; int arr[t]; while ( q > 0 ) { sum = 0; count = 0; scan...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
9b411a4b4a0df7e9c491197724c4774b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <stdlib.h> #include <math.h> int min (int a , int b) { if (a>b) return b; else return a; } int main () { int q , n , count = 0 , sum , i , j = 0 , t , t1 , t2 , o , res , k = 0 , temp ; scanf("%d" , &q); t = q; int arr[t]; while ( q > 0 ) { sum = 0; count = 0; scan...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
6c22eda6d0dee15c89e3984108f87139
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <math.h> int main() { long long int ans,no[500],pp; int num,pwr,arr[100]; scanf("%d",&num); for (int i = 0; i < 100; i++) arr[i] = i; for (int i = 0; i < num; i++) scanf("%lld",&no[i]); for (int i = 0; i < num; i++) { pwr = (int) (log(no[i])/log(3)); ans = (long long int)(pow(3...
The only difference between easy and hard versions is the maximum value of $$$n$$$.You are given a positive integer number $$$n$$$. You really love good numbers so you want to find the smallest good number greater than or equal to $$$n$$$.The positive integer is called good if it can be represented as a sum of distinct...
For each query, print such smallest integer $$$m$$$ (where $$$n \le m$$$) that $$$m$$$ is a good number.
C
5953b898995a82edfbd42b6c0f7138af
0edbb42ef69f2c626a3ba358c715f32b
GNU C11
standard output
256 megabytes
train_003.jsonl
[ "implementation", "greedy", "brute force" ]
1571754900
["7\n1\n2\n6\n13\n14\n3620\n10000"]
null
PASSED
1,300
standard input
1 second
The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains one integer $$$n$$$ ($$$1 \le n \le 10^4$$$).
["1\n3\n9\n13\n27\n6561\n19683"]
#include <stdio.h> #include <math.h> int main() { long long int ans,no[500],pp; int num,pwr,arr[100]; scanf("%d",&num); for (int i = 0; i < 100; i++) arr[i] = i; for (int i = 0; i < num; i++) scanf("%lld",&no[i]); for (int i = 0; i < num; i++) { pwr = (int) (log(no[i])/log(3)); ans = (long long int)(pow(3,pwr+1) - 1) /...