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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | f7d136de4d664dc8f061fc1e024421ae | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include <stdio.h>
#include <string.h>
#include <math.h>
int main() {
int tests, counter = 0;
scanf("%d", &tests);
long long results[tests];
while (tests > 0) {
long long a, b, c, d;
scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
if (b >= a) {
results[counter] = b;
... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 1feba4bdc67526e684affff9d1e722d9 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include<stdio.h>
#define lint long long
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
lint a,b,c,d;
scanf("%lld%lld%lld%lld", &a,&b,&c,&d);
lint ans=b;
if(a-b<=0)
{
printf("%lld\n", b);
continue;
}
if(c-d<=0)
{
... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 7437d4e03e9714a4310594887298b2da | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include <stdio.h>
//����ͬ�ߣ�����ͬ�ı�ֵ��ӣ��жϺ��Ƿ������ͬ��
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
unsigned int a,b,c,d;
scanf("%u %u %u %u",&a,&b,&c,&d);
if(a<=b) printf("%u\n",b);
else if(c<=d) printf("-1\n");
else{
unsigned long long f=... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 346509ee1823efecf8bedda351eca0fe | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include<stdio.h>
#define li long long int
int main()
{
li t,k;
scanf("%lld",&t);
for(k=0;k<t;k++)
{
li a,b,c,d;
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
if(b>=a)
{
printf("%lld\n",b);
continue;
}
if(d>=c)
{
pri... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 7f8037d4b27356bb5909d06ea8d82d86 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] |
#include <stdio.h>
#include <math.h>
int main(){
int numTestCases;
scanf("%d", &numTestCases);
long long int a, b, c, d, t;
for(int i = 0; i < numTestCases; i++){
t = 0;
scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
t += b;
a -= b;
... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 5d26709dc615f3843aaa74d027c0ff31 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include <stdio.h>
int main(){
int t;
scanf("%d",&t);
while(t--){
long long int a,b,c,d,diff,sum,ans,i;
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
long long int f=(a-b)/(c-d);
long long int mod=(a-b)%(c-d);
if(a>b && c>d)
{
if(mod==0)
{
i=f;
sum=b+(i*c);
printf("... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 5c9429fb07d71fa57e1de3c48aa391b3 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include<stdio.h>
int main()
{
long long int t,a,b,c,d;
scanf("%lld",&t);
while(t--){
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
if(b>=a) printf("%lld\n",b);
else if(c<=d) printf("-1\n");
else{
if((a-b)%(c-d)!=0) printf("%lld\... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 5d48fb16007f3d454e0e4b95249f4af9 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include<stdio.h>
int main()
{
long long int t,a,b,c,e,d;
scanf("%lld",&t);
while(t--){
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
if(b>=a) printf("%lld\n",b);
else if(c<=d) printf("-1\n");
else{
e=(((a-b)+(c-d)-1)/(c-d))*c;
... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 3757949faab29a5266f775424c34fa98 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include<stdio.h>
#include<conio.h>
int main(){
int t,i;
long long int a,b,c,d,hasil=0,data[10000];
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%lli %lli %lli %lli",&a,&b,&c,&d);
if(a>b){
if(c>d){
if(((a-b)%(c-d))==0){
hasil = b+((a-b)/(c-d))*c;
}
else{
hasil = b+((a-b)/(c-d)+1)*c;
... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 98eec0c53df3896e68f27c0cb39df32e | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include<stdio.h>
int main()
{
long long int a, b, c, d, p, r, s;
int t, q, i;
scanf("%d", &t);
for(i=1;i<=t;i++)
{
scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
if(b>=a)
printf("%lld\n", b);
else if(c==d)
printf("-1\n");
else
{
... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 17f347a04098c6c0626f8e3094040cb8 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
int a,b,c,d;
long long int e,f,n,s;s=0;
scanf("%d%d%d%d",&a,&b,&c,&d);
if(b>=a)
{
printf("%d\n",b);
}
else
{
e=a-b;
if(d>=c)
{
... | |
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed.Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes.Every time Polycarp wakes up, he decides if he wants ... | For each test case print one integer. If Polycarp never gets out of his bed then print -1. Otherwise, print the time it takes for Polycarp to get out of his bed. | C | 1ab174688ba76168ca047ed2b06b0670 | 0a12242c11d187e129ce7fdd5965aa36 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1589707200 | ["7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000"] | NoteIn the first testcase Polycarp wakes up after $$$3$$$ minutes. He only rested for $$$3$$$ minutes out of $$$10$$$ minutes he needed. So after that he sets his alarm to go off in $$$6$$$ minutes and spends $$$4$$$ minutes falling asleep. Thus, he rests for $$$2$$$ more minutes, totaling in $$$3+2=5$$$ minutes of sle... | PASSED | 900 | standard input | 2 seconds | The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The only line of each testcase contains four integers $$$a, b, c, d$$$ ($$$1 \le a, b, c, d \le 10^9$$$) — the time Polycarp has to sleep for to feel refreshed, the time before the first alarm goes off, the time before every... | ["27\n27\n9\n-1\n1\n6471793\n358578060125049"] | #include<stdio.h>
int main(){
int t;
scanf("%d",&t);
while(t--){
long long a,b,c,d;
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
long long req_time;
if (b>=a) req_time=b;
else if(c-d<=0) req_time=-1;
else if((a-b)%(c-d)==0) req_time=c*(a-b)/(c-d)+b;
else req_time=c*((a-b)/... | |
You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one). | Print on the first line the number of the sought indices. Print on the second line the sought indices in the increasing order. All indices are integers from 1 to n. If the sought elements do not exist, then the first output line should contain number 0. In this case you may either not print the second line or print an ... | C | 1a22bc82ddf6b3dfbf270bc5e3294c28 | a4a26f3a1cfc17b93c667954549e0e6b | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"brute force"
] | 1322838000 | ["5\n1 2 3 4 5", "4\n50 50 50 50"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains the integer n (2 ≤ n ≤ 2·105). The second line contains elements of the sequence a1, a2, ..., an (1 ≤ ai ≤ 1000). All the elements are positive integers. | ["1\n3", "4\n1 2 3 4"] | #include<stdio.h>
main()
{
long long int n, a[200010], i, s, m, b[200010], x;
scanf("%lld", &n);
for (i=0, s=0; i<n; i++)
{
scanf("%lld", &a[i]);
s=s+a[i];
}
m=s/n;
if (m*n!=s)
{
x=0;
}
else
{
for (i=0, x=0; i<n; i++)
{
if (a[i]==m)
{
b[x]=i+1;
x++;
}
}
}
printf("%lld\n", x);
... | |
You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one). | Print on the first line the number of the sought indices. Print on the second line the sought indices in the increasing order. All indices are integers from 1 to n. If the sought elements do not exist, then the first output line should contain number 0. In this case you may either not print the second line or print an ... | C | 1a22bc82ddf6b3dfbf270bc5e3294c28 | 7295db8cef573b49125fe2d7a3d8e5bf | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"brute force"
] | 1322838000 | ["5\n1 2 3 4 5", "4\n50 50 50 50"] | null | PASSED | 1,200 | standard input | 1 second | The first line contains the integer n (2 ≤ n ≤ 2·105). The second line contains elements of the sequence a1, a2, ..., an (1 ≤ ai ≤ 1000). All the elements are positive integers. | ["1\n3", "4\n1 2 3 4"] | #include<stdio.h>
int main()
{
int i, t, A[200000], B[200000], j, count = 0, sum = 0;
scanf("%d", &t);
for(i=0.0; i<t; i++)
{
scanf("%d", &A[i]);
sum += A[i];
}
for(i=0; i<t; i++)
{
if(A[i]*t == sum)
{
B[count] = i+1;
count++;
}... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | 8e2ceb53b64234c36940bf11d2a72c8c | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] |
#include<stdio.h>
main()
{
int t,n,a,b,c,d,i,j,N,M,A,B,s=0;
scanf("%d",&t);
for(i=0;i<t;){
scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
M=a-b;
N=a+b;
A=c-d;
B=c+d;
for(j=M;j<=N;j++){
s=n*j;
... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | ab6432e04faff3dc26a633b203c23efa | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include <stdio.h>
int main()
{
int t,n,a,b,c,d;
scanf("%d",&t);
while (t--)
{
scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
int p=a+b;
int q=(c+d);
int r=a-b;
int s=c-d;
if((p*n<s) || (r*n>q))
{
printf("NO\n");
}
else
{
printf("YES\n");
}
}
return 0;
} | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | 2f20163fd2c7e83cc40dde99a559992a | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include <stdio.h>
#include <math.h>
int main()
{
int i,t, n[1000],a[1000],b[1000],c[1000],d[1000], x,y,z;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d",&n[i]);
scanf("%d",&a[i]);
scanf("%d",&b[i]);
scanf("%d",&c[i]);
scanf("%d",&d[i]);
}
for (i=0;i<t;i++)
{
if(n[i]*(a[i]-b[i])<=(c[i]+d[i]) && n[i]*(a[i]+b[i])>=c[i]-d[... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | 1fa02e9a18fd33e705353699c320d03a | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,a,b,c,d,p,q,x,y,p1,p2;
scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
p=a-b;
q=a+b;
x=c-d;
y=c+d;
int k=0,i;
p1=n*p;
p2=n*q;
if((p1>=x&&p2<=y)||(p1>=x&&p1<=y)||(p... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | 04d041af33262267e1778f793825244a | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include<stdio.h>
int main()
{
long long int n,m,a,b,c,d,i,j,l=0;
scanf("%lld",&n);
while(n--)
{
scanf("%lld %lld %lld %lld %lld",&m,&a,&b,&c,&d);
if((a-b)*m > (c+d) || (a+b)*m < (c-d))
printf("No\n");
else
printf("Yes\n");
}
retur... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | 6afa5c96f4b382b50763025cde4c2d23 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include <stdio.h>
int main()
{
long long int t,n,a,b,c,d,i,res1,res2,res3,res4;
scanf("%lld",&t);
for(i=0;i<t;i++)
{
scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
res1=n*(a-b);
res2=n*(a+b);
res3=c-d;
res4=c+d;
if((res1>res4||res2<res3))
{
... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | 0f49311f1a6204368ad7da6343064090 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include<stdio.h>
int main()
{
int t,n,a,b,c,d,i,x,y,p,q;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
x=(a-b)*n;
y=(a+b)*n;
p=c-d;
q=c+d;
if((x>=p && x<=q) || p>=x && p<=y)
{
printf("Yes\n");
}
... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | aab8614f4141dbdd770815a13e86f22c | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include<stdio.h>
int main(){
int mingrain,maxgrain,minpack,maxpack,g,a,b,c,d,i,n;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d%d%d%d",&g,&a,&b,&c,&d);
mingrain=(a-b)*g;
maxgrain=(a+b)*g;
minpack=c-d;
maxpack=c+d;
if(((mingrain>=minpack)&&(mingrain<=maxpack))||((maxgrain<=maxpack)&&(maxgrain>=m... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | 9d737e1266c84e4ffe77e5ff9d262864 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include<stdio.h>
int main()
{
int t,i;
scanf("%d",&t);
for(i=1;i<=t;i++){
int n,a,b,c,d,j,k,p,q,r,s;
scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
p=a-b;
q=a+b;
r=c-d;
s=c+d;
if((n*p)<=s&&(n*... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | f3656ef091398aa84f942efa769ebd07 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include<stdio.h>
int main()
{
int t,i,j,a,b,c,d,M,N,X,Y,s=0,l=0,n;
scanf("%d",&t);
for(i=1;i<=t;){
scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
M=a-b;
N=a+b;
X=c-d;
Y=c+d;
for(j=M;j<=N;j++){
s=j*n;
if((s>=X&&s<=Y)||(M*n<=X&&N*n>=Y)){
... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | bb950531440d3528f46e7393725cfd7a | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include<stdio.h>
int main ()
{
int t;
scanf("%d",&t);
for (int i=1; i<=t; i++)
{
int n,a,b,c,d;
scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
int r1=n*(a-b);
int r2=n*(a+b);
int r3= c-d;
int r4=c+d;
//printf("%f %f %f %f\n",lo1, lo2,hi1, hi2);
... | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | 9df055084c9412e8ddc1f483ac38a4ab | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,a,b,c,d;
scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
int x=a-b,y=a+b,p=c-d,q=c+d;
x=x*n;y=y*n;
if(!(y<p||x>q))
printf("Yes\n");
else
printf("No\n");
}
} | |
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished.In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $$... | For each test case given in the input print "Yes", if the information about the weights is not inconsistent, and print "No" if $$$n$$$ grains with masses from $$$a - b$$$ to $$$a + b$$$ cannot make a package with a total mass from $$$c - d$$$ to $$$c + d$$$. | C | 30cfce44a7a0922929fbe54446986748 | d70fc65cccc33d9734178ed9c494ffe2 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"math"
] | 1587653100 | ["5\n7 20 3 101 18\n11 11 10 234 2\n8 9 7 250 122\n19 41 21 321 10\n3 10 8 6 1"] | NoteIn the first test case of the example, we can assume that each grain weighs $$$17$$$ grams, and a pack $$$119$$$ grams, then really Nastya could collect the whole pack.In the third test case of the example, we can assume that each grain weighs $$$16$$$ grams, and a pack $$$128$$$ grams, then really Nastya could col... | PASSED | 900 | standard input | 1 second | The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The next $$$t$$$ lines contain descriptions of the test cases, each line contains $$$5$$$ integers: $$$n$$$ $$$(1 \leq n \leq 1000)$$$ — the number of grains that Nastya ... | ["Yes\nNo\nYes\nNo\nYes"] | #include<stdio.h>
int main()
{
int T;
scanf("%d",&T);
while(T--){
int i,n,b,c;
scanf("%d",&n);
int a[4];
for(i=0;i<4;++i)
scanf("%d",&a[i]);
b=a[0]-a[1];c=a[0]+a[1];
for(i=a[2]-a[3];i<=a[2]+a[3];++i){
if(n*c>=i && n*b<=i){
print... | |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | 6e1c6eb18b3845d6cdb7907ef49a61d4 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include<stdio.h>
#include<conio.h>
int main()
{
int i,x,n;
long long k,p;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%lld %d",&k,&x);
p=9*(k-1)+x;
printf("%lld\n",p);
}
return 0;
}
| |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | 7cedb65371825605a64dbfe9af3901b1 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include <stdio.h>
int main (){
long long int k, x, t;
scanf("%lld", &t);
for (int i = 0; i < t; i++){
scanf("%lld %lld", &k, &x);
printf("%lld\n", x+9*(k-1));
}
return 0;
} | |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | 2f3dd1eb1e4600bdb420c4efdc42c0b4 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include<stdio.h>
int main(){
int test;
scanf("%d",&test);
int x;
long long int k;
while(test){
scanf("%lld%d",&k,&x);
k--;
k=k*9+x;
printf("%lld\n",k);
test--;
}
return 0;
} | |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | 9d6e6f2df86c8cce8026ab5b67076c1c | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include <stdio.h>
int main(){
int n;scanf("%d",&n);
long long K[n];int X[n];
int i;
for (i=0;i<n;i++)
scanf("%lld %d",&K[i],&X[i]);
for (i=0;i<n;i++)
printf("%llu\n",(K[i]-1)*9+X[i]);
return 0;}
| |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | 33a75d206bd4bf4104bf156d5060d96b | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include <stdio.h>
int main() {
int n;
scanf("%d", &n);
long long int k, x;
for (int i = 0; i < n; i++) {
scanf("%lld %lld", &k, &x);
printf("%lld\n", x+(k-1)*9);
}
return 0;
} | |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | b2335d9580ea963b2ac78af3e718ef37 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include<stdio.h>
int main()
{
int n,x;
long long k,ans;
scanf("%d",&n);
while(n--)
{
scanf("%I64d %d",&k,&x);
ans=(k-1)*9+x;
printf("%I64d\n",ans);
}
return 0;
}
| |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | 45d30bc2c7ad18575ebacebca1954b13 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include <stdio.h>
int main()
{
long long t, i, n, m;
scanf("%lld", &t);
for (i = 0; i < t; i++){
scanf("%lld %lld", &n, &m);
printf("%lld\n", (n-1)*9 + m);
}
return 0;
}
| |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | 5cc5e791d27c33aec7921178e0cd86e5 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | long long k;main(x){for(scanf("%*d");~scanf("%lld%d",&k,&x);printf("%lld ",--k*9+x));} | |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | f381e2930aa8181205b4938a4847e57a | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
long long int i, j, k, x;
for (i = 1; i <= n; i++)
{
scanf("%lld %lld", &k, &x);
long long int res = x + (k - 1) * 9;
printf("%lld\n", res);
}
return 0;
}
| |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | f3bb7205fc4560f17d8755ebdf2868bd | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#define MOD 1000000007
#define PI 3.14159265
#define seive_len 1000001
int *array;
int seive[seive_len];
int prime_prime[seive_len];
int min(int a, int b) {
return a<b?a:b;
}
int max(int a, int b) {
return a>b?a:b;
}
... | |
Today at the lesson of mathematics, Petya learns about the digital root.The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-dig... | Output $$$n$$$ lines, $$$i$$$-th line should contain a single integer — the answer to the $$$i$$$-th problem. | C | 891fabbb6ee8a4969b6f413120f672a8 | 18ae520df4ac180b8fe0ba513472e936 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"math"
] | 1548516900 | ["3\n1 5\n5 2\n3 1"] | null | PASSED | 1,000 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$) — the number of tasks in Petya's homework. The next $$$n$$$ lines contain two integers $$$k_i$$$ ($$$1 \le k_i \le 10^{12}$$$) and $$$x_i$$$ ($$$1 \le x_i \le 9$$$) — $$$i$$$-th Petya's task in which you need to find a $$$k_i$$$-th positive numbe... | ["5\n38\n19"] | #include<stdio.h>
int main()
{
int n,i,j;
long long int k, x;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%lld %lld",&k,&x);
for(j=1;j<k;j++)
{
x+=9;
}
printf("%lld\n",x);
x=0;
}
}
| |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | 0c814a2982c5147e1c3ec4468bcf0e22 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include<stdio.h>
#define MAX(x,y) (((x)<(y))?(y):(x))
int main(void){
int n,i,j,k,count=0,get;
int num[101]={0};
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%d",&num[i]);
if(n<=2 || !(n%2)){
puts("-1");
return 0;
}
for(i=n;i>1;i-=2){
get=MAX(num[i],num[i-1]);
count+=get;
num[i]=num[... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | 83bcd85e6d73b56ac8103ef91535fa45 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int h[200],count=0,n,ok=0;
void jk(int a)
{
int i,l;
if(a%2==0&&h[a]!=0&&a*2+1<=n)
{
count+=h[a];
if(h[a]>=h[a/2]) h[a/2]=0;
else h[a/2]-=h[a];
h[a]=0;
}
else if(a%2==0&&h[a]... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | 217706f5ba700627d7091da9a0ab7d65 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include<stdio.h>
int n,a[109],i,j,ans;
int main()
{
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
if(n%2==0||n==1)
{
printf("-1\n");
return 0;
}
for(i=n;i>=1;i--)
{
if(a[i]>0)
{
ans+=a[i];
j=a[i];
a[i]-=j;
a[i-1]-=j;
a[(i-1)/2]-=j;
}
i--;
if(a[i]... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | 5df482982c7d498e1b0c204cfa6b07be | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include<stdio.h>
#include<stdlib.h>
int a[105]={0};
int main()
{
int k,i,n,ans=0;
scanf("%d",&n);
for(k=1;k<=n;k++)
scanf("%d",&a[k]);
if(n==2||n==1||n%2==0)
{printf("-1\n");return 0;}
else
{
for(;;)
{
for(k=n;k>=1;k--)
if(a[k]>0)
... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | 600e6069d0fd0f39d192486d82d5c420 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include <stdio.h>
#include <stdlib.h>
int n,a[101];
int main()
{ int i,j,k,step=0;
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%d",&a[i]);
if(n<=1 || n%2==0)
{ printf("-1");
return 0;
}
for(i=n;i>0;i--)
{ if(a[i]>0)
{ step+=a[i];
k=i-1;
... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | ba0888a9befc09ec0bfeecb363bf9b53 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include <stdio.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int a[100];
void solve(int n)
{
int i, ans, t;
if (n == 1 || (n & 1) == 0)
{
printf("-1\n");
return;
}
ans = 0;
for (i = n >> 1; i > 0; i --)
{
t = MAX(a[(i << 1) - 1], a[i << 1]);
ans += t;
... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | dc38d33ed0cbb7b604c7d9a5709082d3 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include <stdio.h>
#define NN 128
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
int main(void)
{
int n, i, a[NN], sum, k;
while (scanf("%d", &n) != EOF) {
for (i = 1; i <= n; i++) {
scanf("%d", a + i);
}
if (n % 2 == 0 || n == 1) {
puts("-1");
continue;
}
sum = 0;
for (i = n / 2; i >= 1; i--) {
k = MAX(... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | 2b466495ce612b8d73e2ee3e51803aff | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include <stdio.h>
#include <stdlib.h>
int max(int a , int b)
{
return(a > b ? a : b);
}
int main()
{
int n , i , l;
long long counter = 0;
scanf("%d" , &n);
int A[n + 5];
A[0] = 0;
for(i = 1;i < n + 1;i++)
{
scanf("%d" , &A[i]);
}
if(!(n & 1) || n == 1)
printf(... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | 2175597e1a5e260643707a35a84f741b | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include <stdio.h>
int main()
{
int N,i,Sum;
int A[101];
scanf("%d",&N);
for(i=1; i<=N; ++i)
{
scanf("%d",&A[i]);
}
if(N<3||N%2==0)
{
puts("-1");
}
else
{
for(Sum=0,i=N; i>=1; --i)
{
if(A[i]>0)
{
Sum+=A[... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | a1ccb80a8f850e6d4d12fe3a03a7346e | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<memory.h>
#include<assert.h>
#include<ctype.h>
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(k) (((k)>0)?(k):(-(k)))
#define mod(a,b) (((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)))
#define ms... | |
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and t... | Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1. | C | 42bfc8dbf45f643782bf42be432cb57c | 6cce20ca785508a0455d35e5569e1a47 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"greedy"
] | 1353339000 | ["1\n1", "3\n1 2 3"] | NoteIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest. | PASSED | 1,700 | standard input | 2 seconds | The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game. | ["-1", "3"] | #include<stdio.h>
int main()
{
int a;
scanf("%d",&a);
int i;
int b[a+1];
for(i=1;i<a+1;i++)
{
scanf("%d",&b[i]);
}
int count=0;
if(a%2==0 || a==1)
{
printf("-1\n");
}
else
{
int y=a/2;
for(i=y;i>=1;i--)
{
int max=b[2*i];
if(b[2*i+1]>max)
{
max=b[2*i+1];
}
count=count+max;
b[... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 6682a0ddd8dd1f057e39e401775ceae8 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
char a[2000][50];
int main(){
int n;
scanf("%d", &n);
char buf[2000];
int ind= 0;
for (int i = 0; i < n; ++i)
{
scanf("%s", &buf);
int length= strlen(buf);
int now= 0;
for (int j = 0; j < length; ++j)
{
int f= 0;
for (int k = 0; k < now;... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | f90e9d55af5d717cf04f6240a567b184 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
int arr[(1<<26)/32],cnt,N,i,j,tmp;
int main(){char str[1001];
for(scanf("%i", &N);i<N;i++,j=tmp=0){
scanf("%s",str);
while(str[j]) tmp|=1<<str[j++]-'a';
if(!(arr[tmp/32] & 1<<tmp%32)) cnt++ , arr[tmp/32]|=1<<tmp%32;
}
printf("%i\n", cnt);
} | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 924ccac5460fa12b6e397afc5e669010 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <stdlib.h>
int
main()
{
int n;
scanf("%d%*c", &n);
int max_len = 1000 * 1001 + 1;
char *buf = malloc(max_len);
fgets(buf, max_len, stdin);
int hash[1000];
int cnt = 0;
int i = 0;
for (int j = 0; j < n; ++j) {
int h = 0;
for (;'a... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 023c7709354e6a8e3af4eb570fcd0247 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <string.h>
int main() {
static char used[1 << 26];
int n, cnt;
scanf("%d", &n);
cnt = 0;
while (n-- > 0) {
static char s[1024];
int len, i, b;
scanf("%s", s);
len = strlen(s);
b = 0;
for (i = 0; i < len; i++)
b |= 1 << (s[i] - 'a');
if (!used[b]) {
used[b] = 1;
... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | cc136c51bd938517ec5f2c87ee30091d | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] |
// https://codeforces.com/problemset/problem/975/A
#include <stdio.h>
#include <string.h>
typedef enum {
False,
True
} bool_t;
typedef enum{
AscendingOrder,
DecendingOrder
} sortorder_t;
typedef struct {
char word[1000];
char root[27];
int root_len;
} aramicword_t;
void SortString(char * string, int str_l... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | bc8bb5078795bda28e1a5ad493fc94db | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <string.h>
int main() {
static char used[1 << 26];
int n, cnt;
scanf("%d", &n);
cnt = 0;
while (n--) {
static char s[1024];
int l, i, b;
scanf("%s", s);
l = strlen(s);
b = 0;
for (i = 0; i < l; i++)
b |= 1 << (s[i] - 'a');
if (!used[b]) {
used[b] = 1;
cnt++;
... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 14bc95fd70aab841c93b62055011542d | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <string.h>
typedef struct {
char m_Cnt[26];
} Node_t;
Node_t A[1000];
int Size;
int main()
{
int n;
char s[1001];
char cur[26];
scanf("%d", &n);
for(int i = 0; i < n; ++i) {
scanf("%s", s);
memset(cur, 0, sizeof(cur));
for(int j = 0; s[j]; ++... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | abe5645364895d18f36859cc92b934b4 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
int main()
{
static char used[1<<26], s[1001];
int n, cnt=0, i, l, b;
scanf("%d", &n);
while (n--)
{
scanf("%s", s);
b=0;
for (i = 0; s[i]!='\0'; i++)
b |= 1 << (s[i] - 'a');
if(!used[b])
{
used[b] = 1;
cn... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 4e28b11a9b3e67a9a9b11e7a096582a4 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include<stdio.h>
#include <string.h>
int main()
{
int n,len,i,c=0,letters[1000][26],j,k,flag=0,flag1,c1,len1;
char str[1001],temp[26];
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<26;j++)
letters[i][j]=0;
}
for(i=0;i<n;i++)
{
flag1=0;
flag=0;
len1=0;
scanf("%s",str);
len=strlen(str);
for(j=0;j... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 98662566d83b91a16997887b14c08fb8 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] |
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 10000000
#define LLD "%l" "ld"
char roots[1000][1001];
int main ()
{
int n;
scanf("%d",&n);
int i=0;
for(int i=0;i<n;i++)
{
int alpha[26];
for(int j=0;j<26;j++)... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 4a83edf92925a50805f8188e095ec4ff | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <string.h>
int main()
{
int n, j=0, g=0, u=0;
char a, x[30], z[1000][30];
scanf("%d\n", &n);
for(int i=0; i<n; i++)
{
a=getchar(), strcpy(x, "00000000000000000000000000");
while(a!=' ' && a!='\n')x[a-97]=1, a=getchar();
for(j=0; j<u; j++)
{
... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 33f8d79aa4024aed7ecce16bc965d2f2 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
int main()
{
int n, x[30]={0}, z[1000][30], j=0, g=0, u=0;
char a;
scanf("%d\n", &n);
for(int i=0; i<n; i++)
{
a=getchar();
while(a!=' ' && a!='\n')x[a-97]=1, a=getchar();
for(j=0; j<u; j++)
{
for(g=0; g<26; g++)if(x[g]!=z[j][g])break;
... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | f8bc9c489ad6891db6f6779e144fdd84 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <string.h>
int main()
{
int n, j=0, g=0, u=0;
char a, x[30], z[1000][30];
scanf("%d\n", &n);
for(int i=0; i<n; i++)
{
a=getchar(), memset(x, 0, 26);
while(a!=' ' && a!='\n')x[a-97]=1, a=getchar();
for(j=0; j<u; j++)
{
for(g=0; g<26; g++)... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | b6d16f4f598de8bc22a0c6a5b45f3f58 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
//int isUp(char ch);
//void toUp(char arr[]);
//void toLow(char arr[]);
int isin(char ch, char arr[], int position);
int strcomp(char arr1[], char arr2[]);
//int strcomp(char arr1[][]);
int main()
{
int number, counter =1 ,flag =0;
scanf("%d\n", &number);
char arr[number][1001];
for (int i = ... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | d71678c0937ad5a55a42b19a9b18f8bf | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#define rep(i,a,b) for (int i=a; i<b; i++)
#define ABC 26
void root(char *s, int *siv, int length) {
rep (i,0,length) siv[i]=0;
while (*s) {
siv[*s-'a']=1;
s++;
}
}
int equals(int *objects, int *siv, int index, int length) {
int keep=1,step=index*length;
rep (i,0,l... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | ca6a9f66e6bc93af4c3c77ab578be760 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include<stdio.h>
#include<string.h>
int main()
{
int n,i,p,j,q,m,num=0,v;
scanf("%d",&n);
char s[n+1][1001],t[n][1001],u[n][1001];
for(i=0;i<n;i=i+1)
{
scanf("%s",&s[i]);
}
for(j=0;j<n;j=j+1)
{
q=0;
for(i=97;i<=122;i=i+1)
{
int k=0;
while(s[j][k]!=0)
{
p=... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | f7dc88b816ca23067e3d7292e90d2fd2 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <string.h>
int main()
{
static char used[1 << 26],s[1001];
int n, cnt=0,i,l,b=0;
scanf("%d", &n);
while (n--)
{
scanf("%s", s);
l = strlen(s);
for (i = 0; i < l; i++)
b |= 1 << (s[i] - 'a');
if (!used[b])
{
u... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 313db65e7adadb9c055e0b62ad366df2 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include<stdio.h>
void mergesort(char arr[], int l, int r)
{
if (l < r)
{
int m = l+(r-l)/2;
mergesort(arr, l, m);
mergesort(arr, m+1,r);
merge(arr, l, m, r);
}
}
void merge(char arr[], int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
int L[1+n1], R[1+n2];
for (i = 0; i < n1; i++)
L[i] = arr[l + ... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | 02bd8e9b679ef9849e267c427d563ce0 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <string.h>
int main() {
static char used[1 << 26];
int n, cnt;
scanf("%d", &n);
cnt = 0;
while (n--) {
static char s[1024];
int l, i, b;
scanf("%s", s);
l = strlen(s);
b = 0;
for (i = 0; i < l; i++)
b |= 1 << (s[i] - 'a');
if (!used[b]) {
used[b] = 1;
cnt++;
... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | d3f818269cb4f1c96e1dfa2b0d14e29c | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <string.h>
int main()
{
int n;
scanf("%d",&n);
char s[n][1002];
int i,j,arm_cnt=n;
for(i=0;i<n;i++)
{
scanf("%s",&s[i]);
}
int arm[n][26];
int arm_temp[26];
for(i=0;i<n;i++)
for(j=0;j<26;j++)
arm[i][j]=0;
for(i=0;i<n;i+... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | f8870e0a17d2800fd8801a940f32cc33 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include <stdio.h>
#include <string.h>
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int i,j,k,sum=0,f=0;
char s[1005][1005],flag[1005][27];
memset(s,'\0',sizeof(s));
for(i=0;i<n;i++)
for(j=0;j<26;j++)
flag[i][j]='0';
for(i=0;i<n;i++)
flag... | |
In Aramic language words can only represent objects.Words in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $$$x$$$ of a word $$$y$$$ is the word that contains all letters that appear in $$$y... | Output one integer — the number of different objects mentioned in the given ancient Aramic script. | C | cf1eb164c4c970fd398ef9e98b4c07b1 | af57ab5b54d8ee7e259554b87a9ad380 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"implementation",
"strings"
] | 1525183500 | ["5\na aa aaa ab abb", "3\namer arem mrea"] | NoteIn the first test, there are two objects mentioned. The roots that represent them are "a","ab".In the second test, there is only one object, its root is "amer", the other strings are just permutations of "amer". | PASSED | 900 | standard input | 1 second | The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^3$$$) — the number of words in the script. The second line contains $$$n$$$ words $$$s_1, s_2, \ldots, s_n$$$ — the script itself. The length of each string does not exceed $$$10^3$$$. It is guaranteed that all characters of the strings are small latin le... | ["2", "1"] | #include<stdio.h>
#include<stdlib.h>
int f(char s[])
{
int x=0,d=1,i=0,t[26];
while(i<26) { t[i]=0; i++;}
i=0;
while(s[i]!=0){
t[s[i]-'a']=1;
i++;
}
i=0;
while(i<26){
x+=d*t[i];
d*=2;
i++;
}
return x;
}
int comp(const void *a,const void *b)
{... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 49f10cc410d2c1a871eddc9f5eee3a61 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include <stdio.h>
#include <stdlib.h>
int cmpfunc(const void* a,const void* b)
{
return *(int*)a-*(int*)b;
}
int main()
{
int n,i,arr[100005],o,p,l;
o=p=l=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
if(arr[i]>0)
p++;
else if(arr[i]==0)
o++;
else
l++;
}
// printf("%d %d %d\n",p,l,o);
if(p>... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 5ec3c3e8191f590016897f49a36a9747 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include <string.h>
#include <stdio.h>
#include <math.h>
int s[1000],s1[1000],s2[1000],s3[1000];
int main()
{
int n,i,m,k,a,b,c;
while(scanf("%d",&n)==1)
{
a=0;b=0;c=0;
for(i=0;i<n;i++) scanf("%d",&s[i]);
for(i=0;i<n;i++)
{
if(s[i]<0){s1[a]=s[i];a++;}
... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 76fdbc45628f6f5fccba169eb66cf39b | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include <stdio.h>
int main(void){
int n;
scanf("%d", &n);
int i, j, k, l, a, nums[n];
i = j = k = l = -1;
for(int m = 0; m < n; m++){
scanf("%d", nums+m);
if(nums[m] < 0 && i == -1) i = m;
else if(nums[m] < 0 && j == -1) j = m;
else if(nums[m] < 0 && k == -1) k = m;
else if(nums[m] > 0 &... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 316f0a8cacaad3f13edae34c7f8eabf0 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include<stdio.h>
void swap(int arr[],int a,int b)
{
int c;
c=arr[a];
arr[a]=arr[b];
arr[b]=c;
}
void bubble(int arr[],int ll,int lr)
{
int i,last;
if(ll>=lr)
return;
swap(arr,ll,(ll+lr)/2);
last=ll;
for(i=ll+1;i<=lr;i++)
if(arr[i]<arr[ll])
swap(arr,++la... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | ea0c37f4b9258d1d7ba780a1c051e3f5 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include <stdio.h>
int main(void) {
// your code goes here
int m,i,n=0,p=0,z=0,nc=0,pc=0,zc=0,ctr=0,ct=0;
scanf("%d",&m);
int a[m];
for(i=0;i<m;i++)
{
scanf("%d",&a[i]);
if(a[i]<0)
n++;
else if(a[i]>0)
p++;
else
... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 6ece8f5556fbef7d497f48f67873b3e9 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n, n1 = 0, n2 = 0, i, n3 = 1;
scanf("%d", &n);
int arr[n], arrP[n], arrN[n], arrZ[n];
for (i = 0; i < n; i++){
scanf("%d", &arr[i]);
if (arr[i] < 0) {arrN[n1++] = arr[i];}
else if (arr[i] > 0) {arrP[n2++] = arr[i];}
}
... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 9914d55e84f74506d30498443773846e | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include <stdio.h>
#define MAX 100
int main() {
int neg[MAX] = { -1 };
int pos[MAX] = { -1 };
int zeroCount, posCount, negCount;
int N, i, divMax, restMax, flag;
scanf("%d", &N);
divMax = N / 3;
restMax = N % 3;
negCount = posCount = zeroCount = 0;
flag = 0;
for (i = 0; i < N; i++) {
int buffer;... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 4091a3cf89bdfd27a1075097c802e810 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include <stdio.h>
#include <stdbool.h>
int main()
{
int n, i, j;
int a[100];
int num_positives = 0;
int num_negatives = 0;
int set[100];
int num_in_set[4] = {0, 0, 0, 0};
int negatives_in_set_2 = 0;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
// printf("a[i] = %d\n", a[i]);
if (a[... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 5914f48a95644b895079f23374a7268e | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
int i,j,t,t2,n[101],p[101],ncnt=-1,pcnt=-1,zcnt=-1;
scanf("%d",&t);
while(t--)
{
scanf("%d",&t2);
if(t2>0)
{
p[++pcnt]=t2;
}else if(t2<0)
{
n[++ncnt]=t2;
}else{
zcnt++;
}
}
printf("1 %... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 3079d92938fede03d052abb300e7b3e4 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i,n,y,a[1000],b[1000],s,l1=0,l2=0,l3=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&y);
if(y<0)
{
a[l1]=y;
l1++;
}
else if(y>0)
{
b[l2]=y;
l2++;
... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | ed5c2a99a51e790150d31526fa436976 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | /*
* Robert Haines 2013
*/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
void print_array(int*, size_t);
int main(void) {
int less[98];
size_t less_num = 0;
int more[98];
size_t more_num = 0;
int zero[98];
size_t zero_num = 0;
int num;
size_t line_len;
int i;
scanf("%d\n", (int*) ... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | a34ce4aec39ef9d8dda0944a927a573b | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
int i,n,flag=0,save1,c=0,flag2=0,save2,c1=0;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]<0)c++;
if(a[i]<0&&flag==0){save1=a[i];flag=1;}
if(a[... | |
Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: The product of all numbers in the first set is less than zero ( < 0). The product of all numbers in the second set is greater than zero ( > 0). The product of all number... | In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set. In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set. In the next... | C | 03cf2cc26c84aab685ee78a1d6318b30 | 452ad800f9a51e2178c3a86ef6178068 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation",
"brute force"
] | 1366903800 | ["3\n-1 2 0", "4\n-1 -2 -3 0"] | null | PASSED | 1,100 | standard input | 2 seconds | The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements. | ["1 -1\n1 2\n1 0", "1 -1\n2 -3 -2\n1 0"] | #include<stdio.h>
#include<string.h>
int main()
{
int n;
scanf("%d",&n);
int a[n],i;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
int arr1[n],arr2[n],arr3[n],a1=0,a2=0,a3=0,z=0,y=0,u=0;
for(i=0;i<n;i++)
{
if(a[i]<0)
{
a1++;
arr1[z]=a[i];
z++;
}
else if(a[i]==0)
{
a2++;
arr2[y]=a[i];
... | |
Let's call a list of positive integers $$$a_0, a_1, ..., a_{n-1}$$$ a power sequence if there is a positive integer $$$c$$$, so that for every $$$0 \le i \le n-1$$$ then $$$a_i = c^i$$$.Given a list of $$$n$$$ positive integers $$$a_0, a_1, ..., a_{n-1}$$$, you are allowed to: Reorder the list (i.e. pick a permutation... | Print the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence. | C | 54e9c6f24c430c5124d840b5a65a1bc4 | 5de5bd678c8d711d9aff62b3a4f5a405 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"sortings",
"brute force",
"math"
] | 1598798100 | ["3\n1 3 2", "3\n1000000000 1000000000 1000000000"] | NoteIn the first example, we first reorder $$$\{1, 3, 2\}$$$ into $$$\{1, 2, 3\}$$$, then increment $$$a_2$$$ to $$$4$$$ with cost $$$1$$$ to get a power sequence $$$\{1, 2, 4\}$$$. | PASSED | 1,500 | standard input | 1 second | The first line contains an integer $$$n$$$ ($$$3 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_0, a_1, ..., a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$). | ["1", "1999982505"] | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 100000000000005
int cmpfunc (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
int main(int argc, char *argv[])
{
int n;
long long i,ans,j,num,min=N;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
qsort(a,n,s... | |
Let's call a list of positive integers $$$a_0, a_1, ..., a_{n-1}$$$ a power sequence if there is a positive integer $$$c$$$, so that for every $$$0 \le i \le n-1$$$ then $$$a_i = c^i$$$.Given a list of $$$n$$$ positive integers $$$a_0, a_1, ..., a_{n-1}$$$, you are allowed to: Reorder the list (i.e. pick a permutation... | Print the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence. | C | 54e9c6f24c430c5124d840b5a65a1bc4 | 57420a52ccf0f4733f84c9432dfb975f | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"sortings",
"brute force",
"math"
] | 1598798100 | ["3\n1 3 2", "3\n1000000000 1000000000 1000000000"] | NoteIn the first example, we first reorder $$$\{1, 3, 2\}$$$ into $$$\{1, 2, 3\}$$$, then increment $$$a_2$$$ to $$$4$$$ with cost $$$1$$$ to get a power sequence $$$\{1, 2, 4\}$$$. | PASSED | 1,500 | standard input | 1 second | The first line contains an integer $$$n$$$ ($$$3 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_0, a_1, ..., a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$). | ["1", "1999982505"] | #include<stdio.h>
long long int h[100005], l;
int comp_h(long long int a, long long int b)
{
if (h[a] > h[b])
return 1;
else
return -1;
}
void swap_h(long long int a, long long int b)
{
long long int f = h[a];
h[a] = h[b];
h[b] = f;
return;
}
void push(long long int ne)
{
h[l] = ne;
long long int p = l;
l+... | |
Let's call a list of positive integers $$$a_0, a_1, ..., a_{n-1}$$$ a power sequence if there is a positive integer $$$c$$$, so that for every $$$0 \le i \le n-1$$$ then $$$a_i = c^i$$$.Given a list of $$$n$$$ positive integers $$$a_0, a_1, ..., a_{n-1}$$$, you are allowed to: Reorder the list (i.e. pick a permutation... | Print the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence. | C | 54e9c6f24c430c5124d840b5a65a1bc4 | 60e83f397728af34a5860705e9cda91f | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"sortings",
"brute force",
"math"
] | 1598798100 | ["3\n1 3 2", "3\n1000000000 1000000000 1000000000"] | NoteIn the first example, we first reorder $$$\{1, 3, 2\}$$$ into $$$\{1, 2, 3\}$$$, then increment $$$a_2$$$ to $$$4$$$ with cost $$$1$$$ to get a power sequence $$$\{1, 2, 4\}$$$. | PASSED | 1,500 | standard input | 1 second | The first line contains an integer $$$n$$$ ($$$3 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_0, a_1, ..., a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$). | ["1", "1999982505"] | #pragma region kyopuro_templates
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
#include<time.h>
#include<ctype.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)f... | |
Let's call a list of positive integers $$$a_0, a_1, ..., a_{n-1}$$$ a power sequence if there is a positive integer $$$c$$$, so that for every $$$0 \le i \le n-1$$$ then $$$a_i = c^i$$$.Given a list of $$$n$$$ positive integers $$$a_0, a_1, ..., a_{n-1}$$$, you are allowed to: Reorder the list (i.e. pick a permutation... | Print the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence. | C | 54e9c6f24c430c5124d840b5a65a1bc4 | 45a5ce7fef471b4196b7c8ab4a4246ca | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"sortings",
"brute force",
"math"
] | 1598798100 | ["3\n1 3 2", "3\n1000000000 1000000000 1000000000"] | NoteIn the first example, we first reorder $$$\{1, 3, 2\}$$$ into $$$\{1, 2, 3\}$$$, then increment $$$a_2$$$ to $$$4$$$ with cost $$$1$$$ to get a power sequence $$$\{1, 2, 4\}$$$. | PASSED | 1,500 | standard input | 1 second | The first line contains an integer $$$n$$$ ($$$3 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_0, a_1, ..., a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$). | ["1", "1999982505"] | #include<stdio.h>
#define LL long long
#define F for(i=0;i<n;i++)
#define R(X) scanf("%lli",&X)
#define W(X) printf("%lli ",X)
#define A(X) ((X)>0?(X):-(X))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define S(X,Y) (&X!=&Y?X^=Y,Y^=X,X^=Y:0)
LL i,j,k,l,m,n,r,t,a[123456];
void qsort(LL *a,LL l,LL r){ // a[l..r]
LL i,j,x;
if(l... | |
Let's call a list of positive integers $$$a_0, a_1, ..., a_{n-1}$$$ a power sequence if there is a positive integer $$$c$$$, so that for every $$$0 \le i \le n-1$$$ then $$$a_i = c^i$$$.Given a list of $$$n$$$ positive integers $$$a_0, a_1, ..., a_{n-1}$$$, you are allowed to: Reorder the list (i.e. pick a permutation... | Print the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence. | C | 54e9c6f24c430c5124d840b5a65a1bc4 | 35a2803400ff37b69eb0ebda12f31cd1 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"sortings",
"brute force",
"math"
] | 1598798100 | ["3\n1 3 2", "3\n1000000000 1000000000 1000000000"] | NoteIn the first example, we first reorder $$$\{1, 3, 2\}$$$ into $$$\{1, 2, 3\}$$$, then increment $$$a_2$$$ to $$$4$$$ with cost $$$1$$$ to get a power sequence $$$\{1, 2, 4\}$$$. | PASSED | 1,500 | standard input | 1 second | The first line contains an integer $$$n$$$ ($$$3 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_0, a_1, ..., a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$). | ["1", "1999982505"] | #include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
int cmp(const void *a, const void *b){
return *(long long *)a-*(long long *)b;
}
long long _abs(long long a){
if(a<0){
return -a;
}
return a;
}
long long arr[100000], power[100000];
int main(void){
int i, j, N, flag, idx;
long long... | |
Let's call a list of positive integers $$$a_0, a_1, ..., a_{n-1}$$$ a power sequence if there is a positive integer $$$c$$$, so that for every $$$0 \le i \le n-1$$$ then $$$a_i = c^i$$$.Given a list of $$$n$$$ positive integers $$$a_0, a_1, ..., a_{n-1}$$$, you are allowed to: Reorder the list (i.e. pick a permutation... | Print the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence. | C | 54e9c6f24c430c5124d840b5a65a1bc4 | 808a1a341d569dd0fda9b84432e4d58d | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"sortings",
"brute force",
"math"
] | 1598798100 | ["3\n1 3 2", "3\n1000000000 1000000000 1000000000"] | NoteIn the first example, we first reorder $$$\{1, 3, 2\}$$$ into $$$\{1, 2, 3\}$$$, then increment $$$a_2$$$ to $$$4$$$ with cost $$$1$$$ to get a power sequence $$$\{1, 2, 4\}$$$. | PASSED | 1,500 | standard input | 1 second | The first line contains an integer $$$n$$$ ($$$3 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_0, a_1, ..., a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$). | ["1", "1999982505"] | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 100000000000005
int cmpfunc (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
void swap(int a[],int i,int j){
int temp;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
void sort(int b[],int start,int end){
int i,last;
if(start>=end)
re... | |
Let's call a list of positive integers $$$a_0, a_1, ..., a_{n-1}$$$ a power sequence if there is a positive integer $$$c$$$, so that for every $$$0 \le i \le n-1$$$ then $$$a_i = c^i$$$.Given a list of $$$n$$$ positive integers $$$a_0, a_1, ..., a_{n-1}$$$, you are allowed to: Reorder the list (i.e. pick a permutation... | Print the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence. | C | 54e9c6f24c430c5124d840b5a65a1bc4 | 3497d8fc2ca7ccbd03066a182e79dec6 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"sortings",
"brute force",
"math"
] | 1598798100 | ["3\n1 3 2", "3\n1000000000 1000000000 1000000000"] | NoteIn the first example, we first reorder $$$\{1, 3, 2\}$$$ into $$$\{1, 2, 3\}$$$, then increment $$$a_2$$$ to $$$4$$$ with cost $$$1$$$ to get a power sequence $$$\{1, 2, 4\}$$$. | PASSED | 1,500 | standard input | 1 second | The first line contains an integer $$$n$$$ ($$$3 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_0, a_1, ..., a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$). | ["1", "1999982505"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int upcmpll(const void *a, const void *b){
return (... | |
Let's call a list of positive integers $$$a_0, a_1, ..., a_{n-1}$$$ a power sequence if there is a positive integer $$$c$$$, so that for every $$$0 \le i \le n-1$$$ then $$$a_i = c^i$$$.Given a list of $$$n$$$ positive integers $$$a_0, a_1, ..., a_{n-1}$$$, you are allowed to: Reorder the list (i.e. pick a permutation... | Print the minimum cost to transform $$$a_0, a_1, ..., a_{n-1}$$$ into a power sequence. | C | 54e9c6f24c430c5124d840b5a65a1bc4 | b2c9fa2c5fc146b4ba0f13d1f15f1fc6 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"number theory",
"sortings",
"brute force",
"math"
] | 1598798100 | ["3\n1 3 2", "3\n1000000000 1000000000 1000000000"] | NoteIn the first example, we first reorder $$$\{1, 3, 2\}$$$ into $$$\{1, 2, 3\}$$$, then increment $$$a_2$$$ to $$$4$$$ with cost $$$1$$$ to get a power sequence $$$\{1, 2, 4\}$$$. | PASSED | 1,500 | standard input | 1 second | The first line contains an integer $$$n$$$ ($$$3 \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_0, a_1, ..., a_{n-1}$$$ ($$$1 \le a_i \le 10^9$$$). | ["1", "1999982505"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int upcmpll(const void *a, const void *b){
return (... | |
Many schoolchildren look for a job for the summer, and one day, when Gerald was still a schoolboy, he also decided to work in the summer. But as Gerald was quite an unusual schoolboy, he found quite unusual work. A certain Company agreed to pay him a certain sum of money if he draws them three identical circles on a pl... | Print a single real number — maximum possible radius of circles. The answer will be accepted if its relative or absolute error doesn't exceed 10 - 6. | C | 8a92946f7c927c236c29ac10568f5079 | 866b0313e71c461a0bb29dffba1b30bf | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"geometry",
"bitmasks",
"sortings",
"binary search",
"brute force"
] | 1374913800 | ["3\n0 1\n1 0\n1 1", "7\n2 -3\n-2 -3\n3 0\n-3 -1\n1 -2\n2 -2\n-1 0"] | null | PASSED | 2,500 | standard input | 9 seconds | The first line contains a single integer n — the number of centers (3 ≤ n ≤ 3000). The following n lines each contain two integers xi, yi ( - 104 ≤ xi, yi ≤ 104) — the coordinates of potential circle centers, provided by the Company. All given points are distinct. | ["0.50000000000000000000", "1.58113883008418980000"] | /* practice with Dukkha */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define N 3000
void srand_() {
struct timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_sec ^ tv.tv_usec);
}
int rand_(int n) {
return (rand() * 76543LL + rand()) % n;
}
int xx[N], yy[N], dd[N][N], aa[N][N ... | |
Many schoolchildren look for a job for the summer, and one day, when Gerald was still a schoolboy, he also decided to work in the summer. But as Gerald was quite an unusual schoolboy, he found quite unusual work. A certain Company agreed to pay him a certain sum of money if he draws them three identical circles on a pl... | Print a single real number — maximum possible radius of circles. The answer will be accepted if its relative or absolute error doesn't exceed 10 - 6. | C | 8a92946f7c927c236c29ac10568f5079 | bd97e658571a22eb530483ce89d80ccb | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"geometry",
"bitmasks",
"sortings",
"binary search",
"brute force"
] | 1374913800 | ["3\n0 1\n1 0\n1 1", "7\n2 -3\n-2 -3\n3 0\n-3 -1\n1 -2\n2 -2\n-1 0"] | null | PASSED | 2,500 | standard input | 9 seconds | The first line contains a single integer n — the number of centers (3 ≤ n ≤ 3000). The following n lines each contain two integers xi, yi ( - 104 ≤ xi, yi ≤ 104) — the coordinates of potential circle centers, provided by the Company. All given points are distinct. | ["0.50000000000000000000", "1.58113883008418980000"] | /* practice with Dukkha */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define N 3000
void srand_() {
struct timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_sec ^ tv.tv_usec);
}
int rand_(int n) {
return (rand() * 76543LL + rand()) % n;
}
int xx[N], yy[N], dd[N][N], aa[N][N ... | |
Many schoolchildren look for a job for the summer, and one day, when Gerald was still a schoolboy, he also decided to work in the summer. But as Gerald was quite an unusual schoolboy, he found quite unusual work. A certain Company agreed to pay him a certain sum of money if he draws them three identical circles on a pl... | Print a single real number — maximum possible radius of circles. The answer will be accepted if its relative or absolute error doesn't exceed 10 - 6. | C | 8a92946f7c927c236c29ac10568f5079 | 17e9cecd59550229e9bb36380fbfd337 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"geometry",
"bitmasks",
"sortings",
"binary search",
"brute force"
] | 1374913800 | ["3\n0 1\n1 0\n1 1", "7\n2 -3\n-2 -3\n3 0\n-3 -1\n1 -2\n2 -2\n-1 0"] | null | PASSED | 2,500 | standard input | 9 seconds | The first line contains a single integer n — the number of centers (3 ≤ n ≤ 3000). The following n lines each contain two integers xi, yi ( - 104 ≤ xi, yi ≤ 104) — the coordinates of potential circle centers, provided by the Company. All given points are distinct. | ["0.50000000000000000000", "1.58113883008418980000"] | /* practice with Dukkha */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define N 3000
void srand_() {
struct timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_sec ^ tv.tv_usec);
}
int rand_(int n) {
return (rand() * 76543LL + rand()) % n;
}
int xx[N], yy[N], dd[N][N], aa[N][N ... | |
Many schoolchildren look for a job for the summer, and one day, when Gerald was still a schoolboy, he also decided to work in the summer. But as Gerald was quite an unusual schoolboy, he found quite unusual work. A certain Company agreed to pay him a certain sum of money if he draws them three identical circles on a pl... | Print a single real number — maximum possible radius of circles. The answer will be accepted if its relative or absolute error doesn't exceed 10 - 6. | C | 8a92946f7c927c236c29ac10568f5079 | 45e5b9ce5db0c549515e2d8059af90c3 | GNU C11 | standard output | 256 megabytes | train_003.jsonl | [
"geometry",
"bitmasks",
"sortings",
"binary search",
"brute force"
] | 1374913800 | ["3\n0 1\n1 0\n1 1", "7\n2 -3\n-2 -3\n3 0\n-3 -1\n1 -2\n2 -2\n-1 0"] | null | PASSED | 2,500 | standard input | 9 seconds | The first line contains a single integer n — the number of centers (3 ≤ n ≤ 3000). The following n lines each contain two integers xi, yi ( - 104 ≤ xi, yi ≤ 104) — the coordinates of potential circle centers, provided by the Company. All given points are distinct. | ["0.50000000000000000000", "1.58113883008418980000"] | /* practice with Dukkha */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define N 3000
void srand_() {
struct timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_sec ^ tv.tv_usec);
}
int rand_(int n) {
return (rand() * 76543LL + rand()) % n;
}
int xx[N], yy[N], dd[N][N], aa[N][N ... | |
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ... | In a single line print the required string. If there isn't such string, print "-1" (without the quotes). | C | 2f659be28674a81f58f5c587b6a0f465 | 6c9c40ce0c611292cd92af4fa8306eb5 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation"
] | 1364916600 | ["7 4", "4 7"] | null | PASSED | 1,300 | standard input | 2 seconds | A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters. | ["ababacd", "-1"] | #include <stdio.h>
#include <string.h>
#include <math.h>
char s1[1000010];
int main()
{
int i,j,n,m,s,t;
while(scanf("%d %d",&n,&m)!=EOF)
{
if(n<m)
{
printf("-1\n");
continue;
}
if(m==1&&n>1)
{
printf("-1\n");
continue;
... | |
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ... | In a single line print the required string. If there isn't such string, print "-1" (without the quotes). | C | 2f659be28674a81f58f5c587b6a0f465 | 29f1b30f64b8a991d6c2f28bd29202a5 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation"
] | 1364916600 | ["7 4", "4 7"] | null | PASSED | 1,300 | standard input | 2 seconds | A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters. | ["ababacd", "-1"] | #include <stdio.h>
int N, K;
int main(void){
int i;
scanf("%d %d", &N, &K);
if (K > N || (K == 1 && N > 1)){
printf("-1\n");
return 0;
}
i = 0;
while (N-- > 0){
putchar(i + 'a');
if (N <= K - 1){
i++;
} else {
i ^= 1;
}
if (N == K && i == 1){
putchar(1 + 'a');
putchar(0 + 'a');
... | |
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ... | In a single line print the required string. If there isn't such string, print "-1" (without the quotes). | C | 2f659be28674a81f58f5c587b6a0f465 | e3c4a25bae40ed13855eb73e135e8203 | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation"
] | 1364916600 | ["7 4", "4 7"] | null | PASSED | 1,300 | standard input | 2 seconds | A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters. | ["ababacd", "-1"] | #include<stdio.h>
int main(){
long int n,k,i;
scanf("%ld %ld",&n,&k);
char op[1000009];
if(n<k){
printf("-1\n");
}else if(n==k){
long int i;
for(i=0;i<n;i++){
printf("%c",('a'+i));
}
printf("\n");
}else if(k<2){
printf("-1\n");
... | |
Little penguin Polo adores strings. But most of all he adores strings of length n.One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No two neighbouring letters of ... | In a single line print the required string. If there isn't such string, print "-1" (without the quotes). | C | 2f659be28674a81f58f5c587b6a0f465 | 95ca9d74e583ed7172e4dc792efbd04a | GNU C | standard output | 256 megabytes | train_003.jsonl | [
"constructive algorithms",
"implementation"
] | 1364916600 | ["7 4", "4 7"] | null | PASSED | 1,300 | standard input | 2 seconds | A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters. | ["ababacd", "-1"] | #include<stdio.h>
#include<math.h>
#include<stdlib.h>
int N,k;
void init();
int main()
{
init();
return 0;
}
void init()
{
int i;
scanf("%d%d",&N,&k);
if((N<k)||(k==1&&N>1))
{
printf("-1\n");
return ;
}
if(k==1&&N==1){
printf("a\n");
return ;
};
f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.