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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | b409a55a7e9889f23887da14b3e0dad4 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
int main()
{
int i, n, k, a[100005];
scanf("%d %d", &n, &k);
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (i = 1; i <= 2000000000; i++)
{
if (k - i > 0)k -= i;
else
{
printf("%d", a[k]);
break;
}
}
} | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | f90d6fe1babcc16e3e5d3808d193152a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#define N 100000
int main() {
static int aa[N];
int n, i;
long long k;
scanf("%d%lld", &n, &k), k--;
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (i = 1; i <= n; i++)
if (k >= i)
k -= i;
else {
printf("%d\n", aa[k]);
return 0;
}
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 22978e109a90581a702c86e3928859a9 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<math.h>
int main()
{
long long int n, k, s, i, y;
double x;
scanf("%lld %lld", &n, &k);
long long int a[n+1];
for(i=0; i<n; i++)
{
scanf("%lld", &a[i]);
}
x=(-1+sqrt(1+(8*k)))/2;
s=x/1;
y=s;
s=k-((s*(s+1))/2);
if(s==0)
{
printf("%lld", a[y-1]);
}
else
{
printf("%ll... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 1d4401ceca0abbfce28b0fda7e23b1a5 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
long long int k,sum,sum2,n,i;
int pos;
scanf("%lld %lld",&n ,&k);
int ara[100000];
for(i=0;i<n;i++)
scanf("%lld",&ara[i]);
for(i=1;i<=n;i++){
sum=i*(i+1);
sum=sum/2;
if(sum>=k)
{sum2=(i-1)*i;
sum2=sum2/2... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | cf387ef2460c7b042359d7fc7c7f952a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
int main()
{
long int n,k;
scanf("%ld%ld",&n,&k);
long int a[1000000],b[1000000];
long int i;
for(i=0;i<n;i++)
scanf("%ld",&a[i]);
long int d=0,j;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
b[j]=a[j];
d++;
... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 60186e621234ae05fd272b6864c2d9d7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int a[10000002],n,i;
long long int k;
scanf("%d%lld",&n,&k);
k--;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n;i++)
{
if(k>=i)
k=k-i;
else
{
printf("%d\n",a[k]);
retu... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 685cc9c28d3b14e1c1732d5b0008e641 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{
long long int n,k,i,x,y;
scanf("%lld %lld",&n,&k);
long long int a[n];
for(i=0;i<n;i++)
scanf("%lld",&a[i]);
x=(sqrt(1+8*k)-1)/2;
y=x*(x+1)/2;
if(y==k)
printf("%lld",a[x-1]);
else
printf("%lld",a[k-y-1]);
} | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 359635ae08f5ade0c8a1b9b28c60616e | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
long long int n,k,i,j,temp=0,flag=0,sub,res;
long long int a[100004];
scanf("%I64d%I64d",&n,&k);
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
for(j=1;j<=n;j++)
{
temp=((j*(j-1))/2)+1;
if(temp<=k)
{
... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | e2cc38fbd5ee124e046ba00d242f7532 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include <stdlib.h>
int main()
{long long int n,k, i, j, sum = 0, robot, sum2 = 0;
scanf("%I64d %I64d",&n,&k);
long long int identifier[n];
for(i = 0; i < n; i++)
{
scanf("%I64d",&identifier[i]);
}
for(i = 1; sum < k ;i++)
{
sum = (((i)*(i+1)) / 2) ;
}
robot = i - 1;
//printf("rob... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 599811c65931c4d3af5029496399d96a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{
long long int n,k, j = 1,i,a;
scanf("%I64d %I64d", &n, &k);
long long int ara[n + 1];
ara[0] = 0;
for(i = 1; i <= n; i++)
{
scanf("%I64d", &ara[i]);
}
while(1)
{
a = j * (j + 1) / 2;
if(a > k)
{
j = j - 1;
... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | f3c31335605a8ef4791644b313fc4fc7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
long long int n,k,p;
scanf("%lld %lld",&n,&k);
long long int a[n+2],i,id[n];
for(i=1;i<=n+1;i++)
{a[i]=(i*(i+1))/2;}
for(i=0;i<n;i++)
{scanf("%lld",&id[i]);}
for(i=1;i<=n+1;i++)
{long long int w=(k/a[i]);
... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | a9f7ef17dff7b2fb77017ad21eaad722 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main(void)
{
long long int n,k,x=0;
scanf("%lld%lld",&n,&k);
long long int a[n+1];
long long int j,i;
for(i=0;i<n;i++)
{
scanf("%lld",&a[i]);
}
for(i=1;i<=n;i++)
{
x=i*(i+1)/2;
if(x>=k)
break;
}
i=i-1;
x=i*(i+1)/2;
k=k-x;
if(k==0)
printf("%lld",a[i-1]);
//printf("%ld i \n %... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 5c00cb28b5633346033b36c88cfb886b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include <stdlib.h>
int main(){
int n, k, i, j, aux;
scanf("%d %d", &n, &k);
int v[n], v1[100];
for(i=0;i<n;i++){
scanf("%d", &j);
v[i]=j;
}
i=0;
aux=1;
while(i<k){
for(j=0;j<aux;j++){
v[j];
if(i==k){
bre... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | d8d7a804e10b4c527afeea5f89991a3d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
long long maiornum(long long k){
long long num, i;
i = 0;
num = 1;
while(num < k){
i++;
num = i*(i+1)/2;
}
if(k != (i-1)*i/2) return k - (i-1)*i/2 - 1;
else return i-1;
}
long long robot[111111];
int main(){
long long n, k, i, cont, l;
cont = 0;
scanf("%lld %lld" , &n, &k);
for(i ... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | f5538e411bed264a38b91478d96586a2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<math.h>
int main()
{
int n,k,i,ara[100000];
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
scanf("%d",&ara[i]);
i=1;
while(i<k)
{
k-=i;
i++;
}
printf("%d\n",ara[k-1]);
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | e5104d684488bdcff616173384e2a7b7 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{
int n,k,a[1000009],i,x;
scanf("%d %d",&n,&k);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
x=k;
// printf("%d\n",x);
for(i=1;i<=n;i++)
{
// printf("*");
k=k-i;
if(k==0)
{
// printf("&");
printf("%d\n",a[k+i]);
break;
}
if(k<0)
{
// printf("!");
k=k+i;
printf("... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 76462ff045ad159305911ce83df09ef0 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<complex.h>
#include<string.h>
#define prime 1000000007
int main()
{
long long temp,lol,i,num,find,arr[100005];
scanf("%lli %lli",&num,&find);
for(i=0;i<num;i++)
{
scanf("%lli",&arr[i]);
}
long long count=0;
for(i=0;i<100005;i++)
{
lol=(i*(i+1))... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 231080d01b74fdec912a428b14f8b61b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<math.h>
int main()
{
int n;
scanf("%d",&n);
long k;
scanf("%ld",&k);
long a[n+1];
for(int i=1;i<n+1;i++)
scanf("%ld",&a[i]);
long root=(long)sqrt(k);
long t=((root)*(root+1))/2;
long i=root+1;
while(k>t)
{
t+=i;
i++;
}
i--;
t-=i;
k-=t;
printf("%... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 4afadcd626eade46c528a7a2bf4f5879 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | /* 20160721 JJA Codeforces #350 B.Game of Robots */
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
int n;
int k=0;
int *arr;
int tmp;
int no;
scanf("%d %d", &n, &k);
arr = (int*)malloc(sizeof(int)*n);
for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
tm... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | db19329732a1210ccb614a557af91936 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{
long long n,p=0;
int f=0;
long long k,sum=0;
scanf("%lld%lld",&n,&k);
long long ar[n];
for(long long i=0;i<n;i++)
scanf("%lld",&ar[i]);
for(long long i=1;i<=n&&sum<k;i++)
{
sum=((i+1)*i)/2;
// printf("%lld\n",sum);
if(sum==k)
{
f=1;
... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | eaf4533e6542243fcc5b90b7dee9ba6f | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include <stdlib.h>
int n, i;
long long k, j, step;
long long id[100000];
long long result;
//B
int main()
{
scanf("%d", &n);
scanf("%I64d", &k);
for (i = 0; i < n; i++)
scanf("%I64d", &id[i]);
result = 0;
for (j = 1; j <= k; j++)
{
result += j;
step =... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | e36202364a12af475a072cee80646efe | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,k,i,done=0;
scanf("%d%d",&n,&k);
int ide[100005];
for(i=0;i<n;i++)
scanf("%d",&ide[i]);
for(i=0;i<n;i++)
{
done=done+(i+1);
if(done>=k)
break;
}
done=done-(i+1);
i=k-done-1;
printf("%d"... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 1d5748cc7f7000472dc74060557bdc5d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,k,i,done=0;
scanf("%d%d",&n,&k);
int ide[n];
for(i=0;i<n;i++)
scanf("%d",&ide[i]);
for(i=0;i<n;i++)
{
done=done+(i+1);
if(done>=k)
break;
}
done=done-(i+1);
i=k-done-1;
printf("%d",ide[... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 7c3a0bcac68ee155af647e579becfdea | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
int main()
{
long n,k,i,j,t,sum=0;
long a[100005]={0};
scanf("%ld %ld",&n,&k);
for(i=1;i<=n;i++)
{
scanf("%ld",&a[i]);
}
for(i=0;i<=n;i++)
{
if((sum+i)>=k)
break;
else
sum+=i;
} ... | |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 95688e22a1609a5ee4e9039b466fd546 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<math.h>
int main()
{
int n,k,i,ara[100000];
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
scanf("%d",&ara[i]);
i=1;
while(i<k)
{
k-=i;
i++;
}
printf("%d\n",ara[k-1]);
return 0;
}
| |
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. After... | Print the k-th pronounced identifier (assume that the numeration starts from 1). | C | 9ad07b42358e7f7cfa15ea382495a8a1 | 737a591f2c13cac313943587e3b1ccc6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1462464300 | ["2 2\n1 2", "4 5\n10 4 18 3"] | NoteIn the first sample identifiers of robots will be pronounced in the following order: 1, 1, 2. As k = 2, the answer equals to 1.In the second test case identifiers of robots will be pronounced in the following order: 10, 10, 4, 10, 4, 18, 10, 4, 18, 3. As k = 5, the answer equals to 4. | PASSED | 1,000 | standard input | 1 second | The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(2·109, n·(n + 1) / 2). The second line contains the sequence id1, id2, ..., idn (1 ≤ idi ≤ 109) — identifiers of roborts. It is guaranteed that all identifiers are different. | ["1", "4"] | #include<stdio.h>
#include<string.h>
int main(void)
{
int i=0,a[100006],n,k,temp = 0;
int sum[100006]={0};
scanf("%d%d",&n,&k);
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
i=1;
sum[0]=0;
for(i=1;i<=n;i++)
{
sum[i] = sum[i-1] + i;
}
for(i=1;i<=n;i++)
{
... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 52cf712d6607f30070e32073e03698d1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
int main( void ) {
int i;
int n, k, h[ 150000 ], sum, min, idx;
scanf( "%d %d", &n, &k );
for ( i = 0; i < n; i++ )
scanf( "%d", h + i );
sum = 0;
for ( i = n - k; i < n; i++ )
sum += h[ i ];
min = sum;
idx = n - k;
for ( i = n - k - 1; i >= 0;... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | a1fdd12cf9953cec1f2c12ea1aeb3d77 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
int sum[ 150000 ];
int main( void ) {
int i;
int n, k, h[ 150000 ], min, idx;
scanf( "%d %d", &n, &k );
for ( i = 0; i < n; i++ )
scanf( "%d", h + i );
for ( i = n - k; i < n; i++ )
sum[ n - k ] += h[ i ];
for ( i = n - k - 1; i >= 0; i-- )
sum[ i ... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 7654b361acf08df059bdfa48fb3cd22a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
int main()
{
int num[200000], n, k, i, j, min=0, sum=0, index=1;
scanf("%d %d", &n, &k);
for(i=0;i<n;i++)
{
scanf("%d", &num[i]);
}
if(n==1)
{
printf("%d", n);
}
else
{
for(i=0;i<k;i++)
{
min+=num[i];
}
... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 43e855bd5c19bf312f29360902c415fa | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include<stdio.h>
#include<stdlib.h>
int main() {
int nPlanks;
int piano;
int *plankHeights = malloc(150000 * sizeof(int));
int start;
int sum;
int i;
int windowSum;
scanf("%d%d", &nPlanks, &piano);
for (i=0; i<nPlanks; i++)
scanf("%d", plankHeights+i);
for (windowSum=0, start=1, i=0; i<pia... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 8fd8e1d738560a2372802726c7c75f5a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include "stdio.h"
int main()
{
int n,k,i,x=0;
scanf("%d%d",&n,&k);
int h[n];long long sum[n+1],dp[n-k+2],minimum=10000000000000;sum[0]=0;
for(i=0;i<n;i++)
scanf("%d",&h[i]);
for(i=1;i<=n;i++)
sum[i]=sum[i-1]+h[i-1];
for(i=1;i<n-k+2;i++)
dp[i]=sum[i+k-1]-sum[i-1];
for(i=1;i<n-k+2;i++)
if(minimum>dp[i])
... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 2c429cd16050e7632cf76a451019fa7d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include<stdio.h>
#include<stdlib.h>
int planks[150009],sum[150009];
int main()
{
int i,n,k,sum1=0,min=100000000,res;
scanf("%d%d",&n,&k);
sum[0]=0;
for(i=1;i<=n;i++)
{
scanf("%d",&planks[i]);
}
for(i=1;i<k;i++){sum1=sum1+planks[i];sum[i]=0;}
for(i=k;i<=n;i++)
{
sum... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 95a9e5901d0068cd65c024ba2537a33a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
#include <limits.h>
int main()
{
int n, k, min, mini, i, sum;
scanf("%d %d", &n, &k);
int cdf[n+1];
cdf[0] = 0;
for (i = 1; i < n+1; i++) {
scanf("%d", &cdf[i]);
cdf[i] += cdf[i-1];
}
min = INT_MAX;
i = 1;
do {
sum = cdf[i+k-1] - cdf[i-1];
if (sum < min) {
mini = i;
min = sum;... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 6569a85b58cd1be2461854e3124afedb | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include<stdio.h>
int n,k,fnc[150003],min=0,sum=0,strt=0,end;
int main(){
int i,j,temp;
scanf("%d %d",&n,&k);
end=strt+k;
for(i=0;i<n;i++)scanf("%d ",&fnc[i]);
for(i=1;i<=end;i++)sum+=fnc[i];
//
min=sum;
for(i=1;n>end;i++){
sum-=fnc[i-1];
sum+=fnc[end];... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 56664ee307265746f123d074613c2613 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include<stdio.h>
int sum(int a[],int i,int k){
int s=0,j;
for(j=i;j<i+k;j++)
s+=a[j];
return s;
}
int main(){
int n,i,j=0,mn,k,t;
scanf("%d %d",&n,&k);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
t=sum(a,0,k),mn=t;
for(i=1;i+k-1<n;i++){
t=t+a[i+k-1]-a[i-1];... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 9ef384e3b2dc93e6601184ac674df093 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include<stdio.h>
int main(){
int n, k;
int menori, menor;
scanf("%d %d", &n, &k);
int heights[n];
int i;
for(i = 0; i < n; i++){
scanf("%d", &heights[i]);
}
if (k == 1){
menor = heights[1];
menori = 1;
for(i = 0; i < n; i ++){
if (menor > hei... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 82bf593f2252e72710c2d6ae26033881 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | /*B*/
#include<stdio.h>
#define maxn 150000+1000
int main()
{
int n,k;
int h[maxn],s[maxn],a[maxn];
int min;
int ans;
while(scanf("%d%d",&n,&k)!=EOF)
{
int i;
for(i=0;i<n;i++)
scanf("%d",&h[i]);
s[0]=h[0];
for(i=1;i<n;i++)
s[i]=s[i-1]+h[i];
a[0]=s[k-1];
for(i=1;i<=n-k;i++)
a[i]=s[i+k-1]-s[... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 0d2229910072700aa70e5cc1c5693f17 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
int main()
{
long long i,n,k,min=15000001,ans;
int h;
scanf("%I64d %I64d",&n,&k);
long long sum[150005];
sum[0]=0;
for(i=1;i<=n;i++){
scanf("%d",&h);
sum[i]=sum[i-1]+h;
}
for(i=k;i<=n;i++){
if(sum[i]-sum[i-k]<min){
ans=i-k+1;
... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | e4a82faca80344b019fe3120999de4c6 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include<stdio.h>
int a[150005];
int main(){
int n,k,i;
scanf("%d%d",&n,&k);
for(i = 1;i <= n;i++){
scanf("%d",a+i);
a[i] += a[i-1];
}
int o = k;
for(i = k;i <= n;i++){
if(a[i]-a[i-k] < a[o]-a[o-k])
o = i;
}
printf("%d",o-k+1);
}
| |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 7e2b7c6eb0b86da72fd611abd9a114a9 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
int main(void)
{
int n,k,i,j,a[150010],sum[150010],flag;
while(scanf("%d%d",&n,&k)!=EOF)
{
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum[i]=0;
}
int min;
for(i=0;i<k;i++)
sum[0]+=a[i];
min=sum[0];
flag=0;
for(i=1;i<n-k+1;i++)
{
... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | d9aa575908193756386f505e57673ffb | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
int solve(int n, int k, int a[])
{
int i, j;
i = 1;
j = k;
int sum = 0;
int it;
for (it = 0; it < k; ++it) {
sum += a[it];
}
int min_sum = sum;
int min_pos = 1;
while (j < n) {
sum += a[j];
sum -= a[i-1];
if (sum < min_sum) {
... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 4e6222671b2de974fb8de9bc134efede | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int s[160000];
int main()
{
int n,k,i,j;
int min,sum,temp;
while(scanf("%d%d",&n,&k)!=EOF)
{
for(i=0; i<n; i++)
{
scanf("%d",&s[i]);
}
sum = 0;
for(i=0; i<k; i++)
{
sum += s... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 7a03783dfb9fc4b5ae4ab929b6141026 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
int a[150005];
int main() {
int n, k;
int mid = 0;
scanf("%d%d", &n, &k);
for(int i = 0; i < n; i++) {
scanf("%d", a + i);
if(i < k)
mid += a[i];
}
int ans = 1, min = mid;
for(int i = k; i < n; i++) {
mid += a[i] - a[i - k];
if(m... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | d8d5cd691fec10f57e98d900e76f9037 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include<stdio.h>
#define MAX 1500000
int main(){
long n,k,i,index=-1;
unsigned long long height[MAX],minHeight[MAX];
unsigned long long minHt=10000001;
scanf("%li",&n);
scanf("%li",&k);
for(i=0;i<n;i++)
scanf("%llu",&height[i]);
minHeight[0]=height[0];
for(i=1;i<k;i++){
... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 0de6f008db2e7ff6bcdafe6e026e0cf7 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
#define MAX 150003
#define MIN 999999999
int main(){
int n, k, i, x, sum, poz = -1, min = MIN, j, v[MAX];
scanf("%d %d",&n,&k);
j = 0;
sum = 0;
for(i = 1;i <= n; ++i){
scanf("%d",&v[i]);
sum = sum + v[i];
++j;
if(j == k){
if(sum < min... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | e30b6f09a3dbe3442724c9f38b666eb4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include<stdio.h>
int num[10000005];
int main(){
int i,j,k,sum,n,a,b,temp;
scanf("%d%d",&n,&k);
j=1;
for(i=0;i<k;i++){
scanf("%d",&a);
sum+=a;
num[i]=a;
}
temp=sum;
for(;i<n;i++){
scanf("%d",&a);
num[i]=a;
if(sum+num[i]-num[i-k]<temp){
... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 2ea34cc5e0d91175e20f6055991e20a4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int a[150000];
int b[150000];
int main() {
int i;
int n, k;
int min = 0;
scanf("%d%d", &n, &k);
for (i = 0; i < n; i++) {
scanf("%d", a+i);
}
b[0] = 0;
for (i = 0; i < k; i++) {
b[0] += a[i];
}
for (i... | |
There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct planks can have distinct heights. Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] Polycarpus has bought a posh piano and is... | Print such integer j that the sum of the heights of planks j, j + 1, ..., j + k - 1 is the minimum possible. If there are multiple such j's, print any of them. | C | 69f4e340b3f6e1d807e0545ebea1fe2f | 933a83a7121a24119b54cc787661a8c1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"brute force"
] | 1384156800 | ["7 3\n1 2 6 1 1 7 1"] | NoteIn the sample, your task is to find three consecutive planks with the minimum sum of heights. In the given case three planks with indexes 3, 4 and 5 have the required attribute, their total height is 8. | PASSED | 1,100 | standard input | 1 second | The first line of the input contains integers n and k (1 ≤ n ≤ 1.5·105, 1 ≤ k ≤ n) — the number of planks in the fence and the width of the hole for the piano. The second line contains the sequence of integers h1, h2, ..., hn (1 ≤ hi ≤ 100), where hi is the height of the i-th plank of the fence. | ["3"] | #include<stdio.h>
int main() {
int sum=0,i,j,k,l,n,m,max=1000000000,a[200005],rem;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++) {
scanf("%d",&a[i]);
sum += a[i];
if(i>=k-1) {
if(sum < max) {
max = sum;
rem = i-k+1;
}
sum -=... | |
There are $$$n$$$ left boots and $$$n$$$ right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings $$$l$$$ and $$$r$$$, both of length $$$n$$$. The character $$$l_i$$$ stands for the color of the $$$i$$$-th left boot and the character $$$r_... | Print $$$k$$$ — the maximum number of compatible left-right pairs of boots, i.e. pairs consisting of one left and one right boot which have compatible colors. The following $$$k$$$ lines should contain pairs $$$a_j, b_j$$$ ($$$1 \le a_j, b_j \le n$$$). The $$$j$$$-th of these lines should contain the index $$$a_j$$$ of... | C | 6bf3e5a542ebce81c1e6ce7260644a3c | 9cea7c43c88c2f91833a68623804de2d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"greedy"
] | 1553006100 | ["10\ncodeforces\ndodivthree", "7\nabaca?b\nzabbbcc", "9\nbambarbia\nhellocode", "10\ncode??????\n??????test"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains $$$n$$$ ($$$1 \le n \le 150000$$$), denoting the number of boots for each leg (i.e. the number of left boots and the number of right boots). The second line contains the string $$$l$$$ of length $$$n$$$. It contains only lowercase Latin letters or question marks. The $$$i$$$-th character stands ... | ["5\n7 8\n4 9\n2 2\n9 10\n3 1", "5\n6 5\n2 3\n4 6\n7 4\n1 2", "0", "10\n6 2\n1 6\n7 3\n3 5\n4 8\n9 7\n5 1\n2 4\n10 9\n8 10"] | #include<stdio.h>
#include<string.h>
#include<math.h>
struct xuexi {
int zhi;
int xian;
int wei[150000];
}aa[27][2];
int main(){
char a[150001],b[150001];
int chang,i;
int dnm[150000][2]={0},dui=0;
scanf("%d",&chang);
scanf("%s%s",a,b);
for(i=0;i<27;i++){
aa[i][0].zhi=0;
aa[i][1].zhi=0;
aa[i][0].xian=0;
... | |
There are $$$n$$$ left boots and $$$n$$$ right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings $$$l$$$ and $$$r$$$, both of length $$$n$$$. The character $$$l_i$$$ stands for the color of the $$$i$$$-th left boot and the character $$$r_... | Print $$$k$$$ — the maximum number of compatible left-right pairs of boots, i.e. pairs consisting of one left and one right boot which have compatible colors. The following $$$k$$$ lines should contain pairs $$$a_j, b_j$$$ ($$$1 \le a_j, b_j \le n$$$). The $$$j$$$-th of these lines should contain the index $$$a_j$$$ of... | C | 6bf3e5a542ebce81c1e6ce7260644a3c | 5ad4200caf1b88dd71765f68f50afbf2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"greedy"
] | 1553006100 | ["10\ncodeforces\ndodivthree", "7\nabaca?b\nzabbbcc", "9\nbambarbia\nhellocode", "10\ncode??????\n??????test"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains $$$n$$$ ($$$1 \le n \le 150000$$$), denoting the number of boots for each leg (i.e. the number of left boots and the number of right boots). The second line contains the string $$$l$$$ of length $$$n$$$. It contains only lowercase Latin letters or question marks. The $$$i$$$-th character stands ... | ["5\n7 8\n4 9\n2 2\n9 10\n3 1", "5\n6 5\n2 3\n4 6\n7 4\n1 2", "0", "10\n6 2\n1 6\n7 3\n3 5\n4 8\n9 7\n5 1\n2 4\n10 9\n8 10"] | #include<stdio.h>
int aaa[26][150001],bbb[26][150001];aa[26],bb[26],qi[150001],qj[150001],ii,jj,i,j,p[150001],r[150001],k=0,c;
int main()
{
int q;
scanf("%d ",&q);
char a[q+1],b[q+1];
scanf("%s %s",&a,&b);
for(i=0;i<q;i++)
{
if(a[i]=='?')
{
qi[ii++]=i;
}
... | |
There are $$$n$$$ left boots and $$$n$$$ right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings $$$l$$$ and $$$r$$$, both of length $$$n$$$. The character $$$l_i$$$ stands for the color of the $$$i$$$-th left boot and the character $$$r_... | Print $$$k$$$ — the maximum number of compatible left-right pairs of boots, i.e. pairs consisting of one left and one right boot which have compatible colors. The following $$$k$$$ lines should contain pairs $$$a_j, b_j$$$ ($$$1 \le a_j, b_j \le n$$$). The $$$j$$$-th of these lines should contain the index $$$a_j$$$ of... | C | 6bf3e5a542ebce81c1e6ce7260644a3c | f4617ed53688c0b67228bdf7705ac48e | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"greedy"
] | 1553006100 | ["10\ncodeforces\ndodivthree", "7\nabaca?b\nzabbbcc", "9\nbambarbia\nhellocode", "10\ncode??????\n??????test"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains $$$n$$$ ($$$1 \le n \le 150000$$$), denoting the number of boots for each leg (i.e. the number of left boots and the number of right boots). The second line contains the string $$$l$$$ of length $$$n$$$. It contains only lowercase Latin letters or question marks. The $$$i$$$-th character stands ... | ["5\n7 8\n4 9\n2 2\n9 10\n3 1", "5\n6 5\n2 3\n4 6\n7 4\n1 2", "0", "10\n6 2\n1 6\n7 3\n3 5\n4 8\n9 7\n5 1\n2 4\n10 9\n8 10"] | #include<stdio.h>
int aaa[26][150001],bbb[26][150000];aa[26],bb[26],qi[150001],qj[150001],ii,jj,i,j,p[150001],r[150001],k,c;
int main()
{
int q;
scanf("%d",&q);
char a[q+1],b[q+1];
scanf("%s %s",&a,&b);
for(i=0;i<q;i++)
{
if(a[i]=='?')
{
qi[ii++]=i;
}
... | |
There are $$$n$$$ left boots and $$$n$$$ right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings $$$l$$$ and $$$r$$$, both of length $$$n$$$. The character $$$l_i$$$ stands for the color of the $$$i$$$-th left boot and the character $$$r_... | Print $$$k$$$ — the maximum number of compatible left-right pairs of boots, i.e. pairs consisting of one left and one right boot which have compatible colors. The following $$$k$$$ lines should contain pairs $$$a_j, b_j$$$ ($$$1 \le a_j, b_j \le n$$$). The $$$j$$$-th of these lines should contain the index $$$a_j$$$ of... | C | 6bf3e5a542ebce81c1e6ce7260644a3c | 74b011eddbbf8d6cd35c1ba58e6f471e | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"greedy"
] | 1553006100 | ["10\ncodeforces\ndodivthree", "7\nabaca?b\nzabbbcc", "9\nbambarbia\nhellocode", "10\ncode??????\n??????test"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains $$$n$$$ ($$$1 \le n \le 150000$$$), denoting the number of boots for each leg (i.e. the number of left boots and the number of right boots). The second line contains the string $$$l$$$ of length $$$n$$$. It contains only lowercase Latin letters or question marks. The $$$i$$$-th character stands ... | ["5\n7 8\n4 9\n2 2\n9 10\n3 1", "5\n6 5\n2 3\n4 6\n7 4\n1 2", "0", "10\n6 2\n1 6\n7 3\n3 5\n4 8\n9 7\n5 1\n2 4\n10 9\n8 10"] | #include<stdio.h>
main()
{
int c[27][150000],d[27][150000],e[150000],f[150000],i,n,j,k[27]={0},l[27]={0},num=0,g=0,h=0,m;
char a[150000],b[150000];
scanf("%d",&n);
scanf("%s %s",&a,&b);
for(i=0;i<n;i++)
{
if((a[i]>='a')&&(a[i]<='z'))
{
j=a[i]-97;
}
el... | |
There are $$$n$$$ left boots and $$$n$$$ right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings $$$l$$$ and $$$r$$$, both of length $$$n$$$. The character $$$l_i$$$ stands for the color of the $$$i$$$-th left boot and the character $$$r_... | Print $$$k$$$ — the maximum number of compatible left-right pairs of boots, i.e. pairs consisting of one left and one right boot which have compatible colors. The following $$$k$$$ lines should contain pairs $$$a_j, b_j$$$ ($$$1 \le a_j, b_j \le n$$$). The $$$j$$$-th of these lines should contain the index $$$a_j$$$ of... | C | 6bf3e5a542ebce81c1e6ce7260644a3c | 2eda4a182adb28d4dc1cb486305e98bb | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"greedy"
] | 1553006100 | ["10\ncodeforces\ndodivthree", "7\nabaca?b\nzabbbcc", "9\nbambarbia\nhellocode", "10\ncode??????\n??????test"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains $$$n$$$ ($$$1 \le n \le 150000$$$), denoting the number of boots for each leg (i.e. the number of left boots and the number of right boots). The second line contains the string $$$l$$$ of length $$$n$$$. It contains only lowercase Latin letters or question marks. The $$$i$$$-th character stands ... | ["5\n7 8\n4 9\n2 2\n9 10\n3 1", "5\n6 5\n2 3\n4 6\n7 4\n1 2", "0", "10\n6 2\n1 6\n7 3\n3 5\n4 8\n9 7\n5 1\n2 4\n10 9\n8 10"] | # include <stdio.h>
# include <string.h>
struct xiezi
{
int bian[150000];
int shu;
int xz;
} zuo[27],you[27];
int s1[150000];
int s2[150000];
int main ()
{
int i,j,k,s,n,a,b,c,d;
char f;
for(i=0;i<27;i++)
{
zuo[i].shu=0;
you[i].shu=0;
zuo[i].xz=0;
you[i].xz=0;
}
scanf("%d",&n);
getcha... | |
There are $$$n$$$ left boots and $$$n$$$ right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings $$$l$$$ and $$$r$$$, both of length $$$n$$$. The character $$$l_i$$$ stands for the color of the $$$i$$$-th left boot and the character $$$r_... | Print $$$k$$$ — the maximum number of compatible left-right pairs of boots, i.e. pairs consisting of one left and one right boot which have compatible colors. The following $$$k$$$ lines should contain pairs $$$a_j, b_j$$$ ($$$1 \le a_j, b_j \le n$$$). The $$$j$$$-th of these lines should contain the index $$$a_j$$$ of... | C | 6bf3e5a542ebce81c1e6ce7260644a3c | 9b5667c3900fede27b1ee4046621c780 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"greedy"
] | 1553006100 | ["10\ncodeforces\ndodivthree", "7\nabaca?b\nzabbbcc", "9\nbambarbia\nhellocode", "10\ncode??????\n??????test"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains $$$n$$$ ($$$1 \le n \le 150000$$$), denoting the number of boots for each leg (i.e. the number of left boots and the number of right boots). The second line contains the string $$$l$$$ of length $$$n$$$. It contains only lowercase Latin letters or question marks. The $$$i$$$-th character stands ... | ["5\n7 8\n4 9\n2 2\n9 10\n3 1", "5\n6 5\n2 3\n4 6\n7 4\n1 2", "0", "10\n6 2\n1 6\n7 3\n3 5\n4 8\n9 7\n5 1\n2 4\n10 9\n8 10"] | # include <stdio.h>
# include <string.h>
struct xiezi
{
int bian[150000];
int shu;
int xz;
int ss
} zuo[27],you[27];
int s1[150000];
int s2[150000];
int main ()
{
int i,j,k,s,n,a,b,c,d;
char f;
for(i=0;i<27;i++)
{
zuo[i].shu=0;
you[i].shu=0;
zuo[i].xz=0;
you[i].xz=0;
}
scanf("%d",&n);
... | |
There are $$$n$$$ left boots and $$$n$$$ right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings $$$l$$$ and $$$r$$$, both of length $$$n$$$. The character $$$l_i$$$ stands for the color of the $$$i$$$-th left boot and the character $$$r_... | Print $$$k$$$ — the maximum number of compatible left-right pairs of boots, i.e. pairs consisting of one left and one right boot which have compatible colors. The following $$$k$$$ lines should contain pairs $$$a_j, b_j$$$ ($$$1 \le a_j, b_j \le n$$$). The $$$j$$$-th of these lines should contain the index $$$a_j$$$ of... | C | 6bf3e5a542ebce81c1e6ce7260644a3c | 1c16021c51f90e6c7bb6b4bc387319b6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"greedy"
] | 1553006100 | ["10\ncodeforces\ndodivthree", "7\nabaca?b\nzabbbcc", "9\nbambarbia\nhellocode", "10\ncode??????\n??????test"] | null | PASSED | 1,500 | standard input | 2 seconds | The first line contains $$$n$$$ ($$$1 \le n \le 150000$$$), denoting the number of boots for each leg (i.e. the number of left boots and the number of right boots). The second line contains the string $$$l$$$ of length $$$n$$$. It contains only lowercase Latin letters or question marks. The $$$i$$$-th character stands ... | ["5\n7 8\n4 9\n2 2\n9 10\n3 1", "5\n6 5\n2 3\n4 6\n7 4\n1 2", "0", "10\n6 2\n1 6\n7 3\n3 5\n4 8\n9 7\n5 1\n2 4\n10 9\n8 10"] | #include <stdio.h>
int vr[27][150000], vl[27][150000], pr[27]={0}, pl[27]={0};
int main()
{
int n, i, j, rc[26]={0}, lc[26]={0}, rw=0, lw=0, c=0, x;
scanf("%d", &n);
char r[150001], l[150001];
scanf("%s ", r);
scanf(" %s", l);
for(i=0; i<n; i++){
if(r[i]=='?'){
rw++;
... | |
You desperately need to build some string t. For that you've got n more strings s1, s2, ..., sn. To build string t, you are allowed to perform exactly |t| (|t| is the length of string t) operations on these strings. Each operation looks like that: choose any non-empty string from strings s1, s2, ..., sn; choose an ar... | Print a single number — the minimum money (in rubles) you need in order to build string t. If there is no solution, print -1. | C | adc23c13988fc955f4589c88829ef0e7 | 9c3425c6b6ba1b70882885d73843d858 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"flows",
"graphs"
] | 1351179000 | ["bbaze\n3\nbzb 2\naeb 3\nba 10", "abacaba\n4\naba 2\nbcc 1\ncaa 2\nbbb 5", "xyz\n4\naxx 8\nza 1\nefg 4\nt 1"] | NoteNotes to the samples:In the first sample from the first string you should take characters "b" and "z" with price 1 ruble, from the second string characters "a", "e" и "b" with price 2 rubles. The price of the string t in this case is 2·1 + 3·2 = 8.In the second sample from the first string you should take two chara... | PASSED | 2,000 | standard input | 2 seconds | The first line of the input contains string t — the string that you need to build. The second line contains a single integer n (1 ≤ n ≤ 100) — the number of strings to which you are allowed to apply the described operation. Each of the next n lines contains a string and an integer. The i-th line contains space-separate... | ["8", "18", "-1"] | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXN 210
#define MAXL 110
#define SNK 209
#define SRC 0
typedef struct edge{
int cap;
int cost;
int from;
int to;
struct edge *back_edge;
struct edge *next;
}edge;
edge *g[MAXN];
char niz[MAXN][MAXL];
int letters[255];
edge* f... | |
You desperately need to build some string t. For that you've got n more strings s1, s2, ..., sn. To build string t, you are allowed to perform exactly |t| (|t| is the length of string t) operations on these strings. Each operation looks like that: choose any non-empty string from strings s1, s2, ..., sn; choose an ar... | Print a single number — the minimum money (in rubles) you need in order to build string t. If there is no solution, print -1. | C | adc23c13988fc955f4589c88829ef0e7 | 58da4dcebca3eeffeeaa02fbd6c6e369 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"flows",
"graphs"
] | 1351179000 | ["bbaze\n3\nbzb 2\naeb 3\nba 10", "abacaba\n4\naba 2\nbcc 1\ncaa 2\nbbb 5", "xyz\n4\naxx 8\nza 1\nefg 4\nt 1"] | NoteNotes to the samples:In the first sample from the first string you should take characters "b" and "z" with price 1 ruble, from the second string characters "a", "e" и "b" with price 2 rubles. The price of the string t in this case is 2·1 + 3·2 = 8.In the second sample from the first string you should take two chara... | PASSED | 2,000 | standard input | 2 seconds | The first line of the input contains string t — the string that you need to build. The second line contains a single integer n (1 ≤ n ≤ 100) — the number of strings to which you are allowed to apply the described operation. Each of the next n lines contains a string and an integer. The i-th line contains space-separate... | ["8", "18", "-1"] | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
typedef struct struct_listgraphintcostintflow{
int node, nodeMemory;
int *edgeSize, *edgeMemory;
int **edge, **cost, **flow, **reverse;
} ListGraphIntCostIntFlow;
ListGraphInt... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | da76142981f28f40a2d6bb9e24bb476d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
int n,count=0,i;
int sml[27]={0};
char tmp,k,D;
scanf("%d",&n);
scanf("%c",&tmp);
for(i=0;i<n-1;i++)
{
scanf("%c%c",&k,&D);
sml[k-'a'+1]++;
if(sml[D-'A'+1])
sml[D-'A'+1]--;
else
count++;
}
printf("%d\n",count);
return 0;
}
| |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | d44353345d8cf08f0f6fa04a78b5fbcb | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
char str[200000];
scanf("%s",&str);
int arr[100]={0};
int i,cnt=0;
for(i=0;i<2*n-2;i++)
{
if((int)str[i]>96)
arr[str[i]-'a']++;
else
{
if(arr[str[i]-'A']!=0)
arr[str[i]-'A']--;
else
cnt++;
}
}
printf("%d",cnt);
return 0;
} | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 249bd112e94acec42fd2e8401d8ef427 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
int n,z=0,i;
scanf("%d",&n);
n*=2;
n-=2;
int b[26]={0};
char a;
for(i=0;i<n;i++){
scanf("%c",&a);
if(a>96)
b[a-97]++;
else
if(b[a-65]>0)
b[a-65]--;
}
scanf("%c",&a);
if(a>96)
b[a-97]++;
else
if(b[a-65]>0)
b[a-65]--;
for(i=0;i<26;i++)
z+=b[i];
printf("%d\n",z);
return 0;}
| |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | ffb3952f65274458f88e529a66ff2530 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
#include<string.h>
int main()
{
long int i,j,T,N,k=0,mark[256]={0};
char ch[200000];
scanf("%ld",&N);
getchar();
gets(ch);
T=strlen(ch);
for(i=0;i<T;i++)
{
if(ch[i]>='a'&&ch[i]<='z')
mark[ch[i]]++;
else
{
if(mark[ch[i]-'A'+'a'... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | f5f8690cac9160d9181a316626678b4d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
#include <ctype.h>
#define SIZE 100000
int main()
{
int i, keys[26] = { 0 }, cnt = 0;
char s[SIZE * 2];
scanf ("%*d %s", s);
for (i = 0; s[i]; i++) {
if (islower(s[i]))
keys[s[i] - 'a']++;
else {
if (keys[tolower(s[i]) - 'a'] == 0)
cnt++;
else
keys[tolower(s[i]) - 'a']--;... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 5804ce1fd01b3026cd0cfb6ae54ecefc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
#include<string.h>
#include<math.h>
long long int l[256];
int main() {
long long int a,b,i,j,count=0,n,l1;
char str[1000001];
// while(1) {
scanf("%lld",&n);
scanf("%s",str);
l1=strlen(str);
count=0;
for(i=0;i<l1-1;i+=2)
{
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | ec76b551301052d83a48e763ee3e9450 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
#include<string.h>
#include<math.h>
long long int l[256];
int main() {
long long int a,b,i,j,count=0,n,l1;
char str[1000001];
// while(1) {
scanf("%lld",&n);
scanf("%s\n",str);
l1=strlen(str);
count=0;
for(i=0;i<l1-1;i+=2)
{
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 3c202b7ff899ec6d0ffe5466cd6ab384 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
#include<string.h>
int arr[123]={0};
int arr1[123]={0};
int main()
{
long long int a,b,c,d,i,j=0,count=0;
char ch;
scanf("%lld",&a);
getchar();
while(j<(2*(a-1)))
{
if(j%2==0)
{
ch=getchar();
arr[ch]++;
}
else
{
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 896b352c8da08d887927efdc8a942d1c | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
int n,i,ans,len;
char str[200000];
while(scanf("%d",&n)==1)
{
int mappa[26]={0};
scanf("%s",&str);
ans=0;
len=2*n-2;
for(i=0;i<len;i++)
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | ce4a84c54f324bd585756a75a7070814 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
#include <string.h>
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
int n,i,ans,len;
char str[200000];
while(scanf("%d",&n)==1)
{
int mappa[26]={0};
scanf("%s",&str);
ans=0;
len=strlen(str);
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 33f28da025159fe3da5ec740a13d1fbd | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
char small[26];
int main()
{
int n,state,count=0,k;
long long int i,j;
scanf("%d",&n);
char ch;
ch=getchar();
for(i=0;i<26;i++)
small[i]=0;
for(i=0;i<2*n-2;i++)
{
ch=getchar();
if('a'<=ch && 'z'>=ch)
{
k=ch-'a';
s... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 856cf7fc3f524735704b4c46d9da82f8 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,c,i,b[26];
char a[200000];
while(scanf("%d",&n)!=EOF)
{
getchar();
scanf("%s",a);
c=0;
for(i=0;i<26;i++)
{
b[i]=0;
}
for(i=0;i<n-1;i++)
{
b[a[2*i]-97]++;
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 3d426e0e82f0b1e5ab6ffb3deb907bff | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int len=2*n-2;
char ch[200000];
int i;
scanf("%s",ch);
int arr[26];
for(i=0;i<26;i++)
arr[i]=0;
int sum=0;
for(i=0;i<len;i++)
{
if(ch[i]>=97)
{
int m=(int)ch[i] - 97;
arr[m]+... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | c781647e93552e18df1be3b599ffdc52 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
#include<string.h>
int main()
{
int n;
scanf("%d",&n);
int arr[26];
int i;
for(i=0;i<26;i++)
{
arr[i]=0;
}
char ch[1000000];
scanf("%s",ch);
int len=strlen(ch);
int count=0;
for(i=0;i<len;i... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | eb5d513f76f1bc95af430d03998cd0df | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int x,n,key[26]={0},openRoom,pointer=0,buy=0;
char *string;
scanf(" %d",&n);
string =(char *)malloc((2*n-2)*sizeof(char));
scanf(" %s",string);
while(pointer<=(2*n-4))
{
x=string[pointer]-97;
key[x]++;
openRoom = ... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | e10f7034353fadb484e7d4807bb5e14e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
char arr[1000004];
int b[26]={0};
int main()
{
int n,i,j;
scanf("%d",&n);
int d=0,count=0;
scanf(" %[^\n]",arr);
for(i=0;i<2*(n-1);i++)
{
if(i%2==0)
{
int s=(int)arr[i]-97;
b[s]++;
}
else
{
int h=(int)arr[i]-65;
if(b[h]>0)
{
b[h]--;
count++;
}
}
}
printf("... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | c40d3c5d7c8d512a9ed0cf42dfff5860 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main(int argc,char *argv[]){
int n;
int string[26];
int j;
int k;
for(k=0;k<26;k++){string[k]=0;}
int c,count;
count=0;
scanf("%d",&n);
int limit;
getchar();
limit=2*n-2;
int i=1;
while((c=getchar())!='\n'&& c!=EOF){
if(i%2){
string[c-97]++;
i++;}
else{
if(string[... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | ce6ee286901977369be9d276a28e6aba | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{int n,sum=0,i;
scanf("%d",&n);
char ch[2*n-2];
scanf("%s",&ch);
int a[26]={0};
for(i=0; i<2*n-2; i++)
{if(i%2==0)
a[ch[i]-'a']++;
else
{if(a[ch[i]-'A']>0)
{a[ch[i]-'A']--;}
else
sum++;
}
}
printf("%d\n",sum);
return 0;
}
| |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | e03006ffbf06fad877e049fa6073daf4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] |
#include<stdio.h>
#define LL long long int
int main()
{
int n,i;
scanf("%d",&n);
char st[1000000];
scanf("%s",st);
static int a[26],b[26];
int count=0;
for(i=0;i<2*n-2;i+=2)
{
int c=st[i]-'a';
a[c]++;
int C=st[i+1]-'A';
if (a[C]==0)
count++;
else
a[C]--;
}
printf("%d\n",count... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 9cbc0396d1ede34af2a8a0c81f63cf36 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long int ll;
main()
{
char a[200005];
int n,i;
scanf("%d%s",&n,a);
int cnt[26] = {0};
int ans = 0;
for(i=0;i<(n-1);i++)
{
cnt[a[2*i]-'a']++;
if(cnt[a[2*i+1]-'A']>0)
{
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 579c02587872474697a1a2810fb103d8 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
char a[500000];
int map1[26]={0};
int n,i,j,k,count=0;
scanf("%d\n",&n);
gets(a);
for(i=0;i<(2*n)-2; i++)
{
if(i%2==0)
map1[a[i]-'a']++;
else
if(map1[a[i]-'A'])
map1[a[i]-'A']--;
else
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 62d79404891cb3f344b2bb926cd17e41 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char s[200000];
int n,i,l,count=0;
scanf("%d",&n);
scanf("%s",s);
l = strlen(s);
int a[26];
for(i=0;i<26;i++)
a[i] = 0;
for(i=0;i<l;i++)
{
if(i%2==0)
a[s[i]-'a']++;
else
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | d6b8d5877c5bcacffd631e080546865e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
#include <string.h>
int main()
{
int n,p,i,j;
int a[150];
char x;
scanf("%d",&n);
p=0;
for(i='a';i<='z';i++)
{
a[i]=0;
}
for(i=0;i<=2*n-2;i++)
{
scanf("%c",&x);
if(i%2==1)
{
a[x]++;
}
else
{
if(a[x+32]>0)
{
a... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | a1af9cd66723e3625293f1ac4c4d35cc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
int main(void) {
int n,i;
scanf("%d",&n);
char s[(2*n-2)];
scanf("%s",s);
int k[26];
for(i=0;i<26;i++){
k[i]=0;
}
int x,ans=0,l=strlen(s);
for(i=0;i<l;i++){
k[(int)s[i]-97]++;
i++;
x=((int)s[i])-65;
if(k[x]>0)
k[... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 9e7d2adf216223107b8bef0a958d5109 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
int main()
{
char code[300000];
unsigned long long record[1000];
unsigned long long len, i, n, keycount = 0;
scanf("%d", &n);
scanf("%s", code);
for(i = 0; i<= 2*(n-2); i+=2)
{
record[code[i]- 'a']++;
if(record[code[i+1]- 'A'] == 0)
{
keycount++;
}
else
{
record[code[i+1]-'A'... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 0476924ba4b65035565c635edf1d6bb5 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
#include<string.h>
int main()
{
int n,ans=0,i;
scanf("%d",&n);
int a[26];
for(i=0;i<26;i++)
{
a[i]=0;
}
char str[2*n];
scanf("%s",str);
int l=strlen(str);
for(i=0;i<l;i++)
{
if(i&1)
{
if(a[str[i]-'A'])
{
a[str[i]-'A']--;
}
else
{
ans++;... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 7396d350d13ea0c7ed5cc28de07e2a9c | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
#define maxn 200005
int main()
{
int n = 0,m,ctr;
char s[maxn] = {'\0'};
char keys[27] = {'\0'};
scanf("%d",&n);
m = 2*n-2;
scanf("%s",s);
int i;
for (i = 0; i < m; i++)
{
if ( i%2 == 0)
{
keys[s[i]-'a']++;
}
else
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 5ecb64ac4979a5dfdbc6c246dc449ccc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
int n,i,c=0;
char a[10000000]="";
int b[125]={0};
scanf("%d\n",&n);
for(i=0; ;i++)
{
scanf("%c",&a[i]);
if(a[i]=='\0')
break;
}
for(i=0;a[i]!='\0';i++)
{ if(((int)a[i])>=97 && ((int)a[i])<=122)
{
b[((int)a[i])]+... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 2df94953d5de779ac96ab2267c539e55 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
int n,i,c=0;
char a[10000000]="";
int b[125]={0};
scanf("%d\n",&n);
for(i=0; ;i++)
{
scanf("%c",&a[i]);
if(a[i]=='\0')
break;
}
for(i=0;a[i]!='\0';i++)
{ if(((int)a[i])>=97 && ((int)a[i])<=122)
{
b[((int)a[i])]+... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | b9f16a094acd48f3c75d63bb58715778 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int a[26]={0};
char c;
char ser[1000000];
int count=0;
scanf("%s",ser);
int i=0;
while(ser[i]!='\0')
{
c=ser[i];
if(c>='a'&&c<='z')
{
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | f5c1c984e76b9e522fe7164c964b6ccc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
char str[200000];
int k[130], i, n, x, count=0;
for(i=0; i<130; i++)
k[i]=0;
scanf("%d %s", &n, str);
for(i=0; i<(2*n-2); i++)
{
if(i%2==0)
{
x = (int)(str[i]);
k[x]++;
}
else
{
if(... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 6dd265685b390201f8e23bd8398386a3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | /* Problem: 525A - Vitaliy and Pie */
/* Solver: Gusztav Szmolik */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
unsigned char s[200000];
int main ()
{
unsigned int n;
unsigned int l;
unsigned short i;
unsigned int kc[26];
unsigned int kb;
unsigned int j;
unsigned char k;... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 2861b65207d7b4896d727838c16fd8c1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
char c;
int i,n;
int a[26]={0};
scanf("%d",&n);
int ans=0;
for(i=0;i<=(2*n-2);i++)
{
scanf("%c",&c);
if(c>='a' && c<='z')
{
a[c-'a']++;
}
else
{
if(a[c-'A']!=0)
a[c-'A']--;
else
ans+=1;
... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | b142b4b3288383fb16e437e021ded20a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
int n,c=0,i,d[26]={0};
scanf("%d\n",&n);
char ch1,ch2;
for(i=1;i<=n-1;i++)
{
ch1=getchar();
ch2=getchar();
d[ch1-'a']++;
if(d[ch2-'A']!=0)
d[ch2-'A']--;
else
c++;
}
printf("%d",c);
}
| |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | a92e8992b713ec8029d80359840a05e4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include<stdio.h>
int main()
{
int n,k[26]={0},d[26]={0},ans=0,i;
char s[300010];
scanf("%d\n",&n);
scanf("%s",s);
i=0;
while(s[i])
{
if(s[i]-32==s[i+1])
i=i+2;
else if(k[s[i+1]-'A']>0)
{
k[s[i+1]-'A']--;
k[s[i]-'a']++;
i=i+2;
}
else
{
ans++;
k[s[i]-'a']++;
i=i+2;
}
}
printf("%d\n",ans);
return 0... | |
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You can go from the first room to the second room, from the second room to the third ro... | Print the only integer — the minimum number of keys that Vitaly needs to buy to surely get from room one to room n. | C | 80fdb95372c1e8d558b8c8f31c9d0479 | 5bee177bbdc90877bfe3b66a69c7a52c | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"hashing",
"greedy",
"strings"
] | 1427387400 | ["3\naAbB", "4\naBaCaB", "5\nxYyXzZaZ"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains a positive integer n (2 ≤ n ≤ 105) — the number of rooms in the house. The second line of the input contains string s of length 2·n - 2. Let's number the elements of the string from left to right, starting from one. The odd positions in the given string s contain lowercase Latin le... | ["0", "3", "2"] | #include <stdio.h>
#include <string.h>
int main()
{
long long int n,sum=0;
int alpha[100]={0},i=0;
scanf("%I64d",&n);
char a[2*n-1];
scanf("%s",a);
for(i=0;i<2*n-2;i++){
if(a[i]>='a'&&a[i]<='z') alpha[a[i]-'a']++;
else{
if(!alpha[a[i]-'A']) sum++;
else... | |
You are given a sequence of integers of length $$$n$$$ and integer number $$$k$$$. You should print any integer number $$$x$$$ in the range of $$$[1; 10^9]$$$ (i.e. $$$1 \le x \le 10^9$$$) such that exactly $$$k$$$ elements of given sequence are less than or equal to $$$x$$$.Note that the sequence can contain equal ele... | Print any integer number $$$x$$$ from range $$$[1; 10^9]$$$ such that exactly $$$k$$$ elements of given sequence is less or equal to $$$x$$$. If there is no such $$$x$$$, print "-1" (without quotes). | C | 55297e2a65144323af4d6abd6a6ef050 | 5f7093fd5dcb61a4ee0bf2e43a3e2fb5 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings"
] | 1567258500 | ["7 4\n3 7 5 1 10 3 20", "7 2\n3 7 5 1 10 3 20"] | NoteIn the first example $$$5$$$ is also a valid answer because the elements with indices $$$[1, 3, 4, 6]$$$ is less than or equal to $$$5$$$ and obviously less than or equal to $$$6$$$.In the second example you cannot choose any number that only $$$2$$$ elements of the given sequence will be less than or equal to this... | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains integer numbers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k \le n$$$). The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the sequence itself. | ["6", "-1"] | #include<stdio.h>
#include<stdlib.h>
int arr[200002];
int comparator(const void*a,const void*b)
{ return (*(int*)a-*(int*)b); }
int main()
{
int n,k;
scanf("%d %d",&n,&k);
for(int i=0;i<n;i++)
scanf("%d",&arr[i]);
qsort(arr,n,sizeof(int),comparator);
if(k==0)
{
if(arr[0]>=2)
printf("%d",... | |
You are given a sequence of integers of length $$$n$$$ and integer number $$$k$$$. You should print any integer number $$$x$$$ in the range of $$$[1; 10^9]$$$ (i.e. $$$1 \le x \le 10^9$$$) such that exactly $$$k$$$ elements of given sequence are less than or equal to $$$x$$$.Note that the sequence can contain equal ele... | Print any integer number $$$x$$$ from range $$$[1; 10^9]$$$ such that exactly $$$k$$$ elements of given sequence is less or equal to $$$x$$$. If there is no such $$$x$$$, print "-1" (without quotes). | C | 55297e2a65144323af4d6abd6a6ef050 | a0ffc0c34f6e880795b93a7b04957d69 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings"
] | 1567258500 | ["7 4\n3 7 5 1 10 3 20", "7 2\n3 7 5 1 10 3 20"] | NoteIn the first example $$$5$$$ is also a valid answer because the elements with indices $$$[1, 3, 4, 6]$$$ is less than or equal to $$$5$$$ and obviously less than or equal to $$$6$$$.In the second example you cannot choose any number that only $$$2$$$ elements of the given sequence will be less than or equal to this... | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains integer numbers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k \le n$$$). The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the sequence itself. | ["6", "-1"] | #include<stdio.h>
#include<stdlib.h>
int compare(const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main(void){
long long int n,k;
scanf("%lld %lld",&n,&k);
long long int arr[200001];
for(int i=0;i<n;i++)
scanf("%lld",&arr[i]);
qsort(arr, ... | |
You are given a sequence of integers of length $$$n$$$ and integer number $$$k$$$. You should print any integer number $$$x$$$ in the range of $$$[1; 10^9]$$$ (i.e. $$$1 \le x \le 10^9$$$) such that exactly $$$k$$$ elements of given sequence are less than or equal to $$$x$$$.Note that the sequence can contain equal ele... | Print any integer number $$$x$$$ from range $$$[1; 10^9]$$$ such that exactly $$$k$$$ elements of given sequence is less or equal to $$$x$$$. If there is no such $$$x$$$, print "-1" (without quotes). | C | 55297e2a65144323af4d6abd6a6ef050 | f02725861d2931b12f4774f83644c346 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings"
] | 1567258500 | ["7 4\n3 7 5 1 10 3 20", "7 2\n3 7 5 1 10 3 20"] | NoteIn the first example $$$5$$$ is also a valid answer because the elements with indices $$$[1, 3, 4, 6]$$$ is less than or equal to $$$5$$$ and obviously less than or equal to $$$6$$$.In the second example you cannot choose any number that only $$$2$$$ elements of the given sequence will be less than or equal to this... | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains integer numbers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k \le n$$$). The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the sequence itself. | ["6", "-1"] | #include <stdio.h>
#include <stdlib.h>
int cmp(const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main()
{
int n, k, a[2*100000];
scanf("%d %d", &n, &k);
int i;
for(i=0;i<n;i++) scanf("%d", &a[i]);
qsort(a, n, sizeof(int), cmp);
int x=a[k-1];
int j=k, l=0;
if(k==0)
{
if(a[0]!=1 )prin... | |
You are given a sequence of integers of length $$$n$$$ and integer number $$$k$$$. You should print any integer number $$$x$$$ in the range of $$$[1; 10^9]$$$ (i.e. $$$1 \le x \le 10^9$$$) such that exactly $$$k$$$ elements of given sequence are less than or equal to $$$x$$$.Note that the sequence can contain equal ele... | Print any integer number $$$x$$$ from range $$$[1; 10^9]$$$ such that exactly $$$k$$$ elements of given sequence is less or equal to $$$x$$$. If there is no such $$$x$$$, print "-1" (without quotes). | C | 55297e2a65144323af4d6abd6a6ef050 | 92962ad2c69bdbb1036c0a53caa2c9ea | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings"
] | 1567258500 | ["7 4\n3 7 5 1 10 3 20", "7 2\n3 7 5 1 10 3 20"] | NoteIn the first example $$$5$$$ is also a valid answer because the elements with indices $$$[1, 3, 4, 6]$$$ is less than or equal to $$$5$$$ and obviously less than or equal to $$$6$$$.In the second example you cannot choose any number that only $$$2$$$ elements of the given sequence will be less than or equal to this... | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains integer numbers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k \le n$$$). The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the sequence itself. | ["6", "-1"] | #include <stdio.h>
#include <stdlib.h>
int cmp(const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main()
{
int n, k, a[2*100000];
scanf("%d %d", &n, &k);
int i;
for(i=0;i<n;i++) scanf("%d", &a[i]);
qsort(a, n, sizeof(int), cmp);
int x=a[k-1], j=k, l=0;
if(k==0)
{
if(a[0]!=1 )printf("... | |
You are given a sequence of integers of length $$$n$$$ and integer number $$$k$$$. You should print any integer number $$$x$$$ in the range of $$$[1; 10^9]$$$ (i.e. $$$1 \le x \le 10^9$$$) such that exactly $$$k$$$ elements of given sequence are less than or equal to $$$x$$$.Note that the sequence can contain equal ele... | Print any integer number $$$x$$$ from range $$$[1; 10^9]$$$ such that exactly $$$k$$$ elements of given sequence is less or equal to $$$x$$$. If there is no such $$$x$$$, print "-1" (without quotes). | C | 55297e2a65144323af4d6abd6a6ef050 | befa2b976db960d7954d62305052a5e9 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings"
] | 1567258500 | ["7 4\n3 7 5 1 10 3 20", "7 2\n3 7 5 1 10 3 20"] | NoteIn the first example $$$5$$$ is also a valid answer because the elements with indices $$$[1, 3, 4, 6]$$$ is less than or equal to $$$5$$$ and obviously less than or equal to $$$6$$$.In the second example you cannot choose any number that only $$$2$$$ elements of the given sequence will be less than or equal to this... | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains integer numbers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k \le n$$$). The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the sequence itself. | ["6", "-1"] | #include<stdio.h>
int comparefunc(const void *a,const void *b)
{
return (*(int*)a-*(int*)b);
}
int main()
{
int n,k,str[200001],i;
scanf("%d %d",&n,&k);
for(i=0;i<n;i++){
scanf("%d",&str[i]);
}
qsort(str,n,sizeof(int),comparefunc);
if(str[0]>=2 && k==0)
printf("%d",str[0]-1);
else i... | |
You are given a sequence of integers of length $$$n$$$ and integer number $$$k$$$. You should print any integer number $$$x$$$ in the range of $$$[1; 10^9]$$$ (i.e. $$$1 \le x \le 10^9$$$) such that exactly $$$k$$$ elements of given sequence are less than or equal to $$$x$$$.Note that the sequence can contain equal ele... | Print any integer number $$$x$$$ from range $$$[1; 10^9]$$$ such that exactly $$$k$$$ elements of given sequence is less or equal to $$$x$$$. If there is no such $$$x$$$, print "-1" (without quotes). | C | 55297e2a65144323af4d6abd6a6ef050 | b4648e462cb2d610356feefd07bee9a2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings"
] | 1567258500 | ["7 4\n3 7 5 1 10 3 20", "7 2\n3 7 5 1 10 3 20"] | NoteIn the first example $$$5$$$ is also a valid answer because the elements with indices $$$[1, 3, 4, 6]$$$ is less than or equal to $$$5$$$ and obviously less than or equal to $$$6$$$.In the second example you cannot choose any number that only $$$2$$$ elements of the given sequence will be less than or equal to this... | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains integer numbers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k \le n$$$). The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the sequence itself. | ["6", "-1"] | #include<stdio.h>
void divide(int a[],int n);
void merge(int l[],int r[],int a[],int nl,int nr);
int main(void)
{
int n,i,k;
scanf("%i %i",&n,&k);
int ar[n+1];
ar[0]=0;
for(i=1;i<=n;i++)scanf("%i",&ar[i]);
divide(ar,n+1);
if(k==n)printf("%i",ar[k]);
else if(ar[k+1]>ar[k])
{
... | |
You are given a sequence of integers of length $$$n$$$ and integer number $$$k$$$. You should print any integer number $$$x$$$ in the range of $$$[1; 10^9]$$$ (i.e. $$$1 \le x \le 10^9$$$) such that exactly $$$k$$$ elements of given sequence are less than or equal to $$$x$$$.Note that the sequence can contain equal ele... | Print any integer number $$$x$$$ from range $$$[1; 10^9]$$$ such that exactly $$$k$$$ elements of given sequence is less or equal to $$$x$$$. If there is no such $$$x$$$, print "-1" (without quotes). | C | 55297e2a65144323af4d6abd6a6ef050 | cbc4b38be4e89a7b1b9d15facac53f34 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"sortings"
] | 1567258500 | ["7 4\n3 7 5 1 10 3 20", "7 2\n3 7 5 1 10 3 20"] | NoteIn the first example $$$5$$$ is also a valid answer because the elements with indices $$$[1, 3, 4, 6]$$$ is less than or equal to $$$5$$$ and obviously less than or equal to $$$6$$$.In the second example you cannot choose any number that only $$$2$$$ elements of the given sequence will be less than or equal to this... | PASSED | 1,200 | standard input | 2 seconds | The first line of the input contains integer numbers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k \le n$$$). The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the sequence itself. | ["6", "-1"] | #include<stdio.h>
#include<stdlib.h>
int compare(const void *a,const void *b)
{
return(*(int*)a-*(int*)b);
}
int main()
{
long long int n,k,ans;
scanf("%lld %lld",&n,&k);
long long int arr[n];
for(long long int i=0;i<n;i++)
scanf("%lld",&ar... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.