prob_desc_description
stringlengths
63
3.8k
prob_desc_output_spec
stringlengths
17
1.47k
βŒ€
lang_cluster
stringclasses
2 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
lang
stringclasses
7 values
prob_desc_output_to
stringclasses
3 values
prob_desc_memory_limit
stringclasses
19 values
file_name
stringclasses
111 values
tags
listlengths
0
11
prob_desc_created_at
stringlengths
10
10
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_notes
stringlengths
4
3k
βŒ€
exec_outcome
stringclasses
1 value
difficulty
int64
-1
3.5k
βŒ€
prob_desc_input_from
stringclasses
3 values
prob_desc_time_limit
stringclasses
27 values
prob_desc_input_spec
stringlengths
28
2.42k
βŒ€
prob_desc_sample_outputs
stringlengths
2
796
source_code
stringlengths
42
65.5k
hidden_unit_tests
stringclasses
1 value
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any other inflorescence with number i (i > 1) is situated at the top of bra...
Single line of output should contain one integer number: amount of apples that Arcady will be able to collect from first inflorescence during one harvest.
C
a4563e6aea9126e20e7a33df664e3171
20925897b0138ad8f6a89689b3a74afc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "dfs and similar", "trees", "graphs" ]
1520177700
["3\n1 1", "5\n1 2 2 2", "18\n1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4"]
NoteIn first example Arcady will be able to collect only one apple, initially situated in 1st inflorescence. In next second apples from 2nd and 3rd inflorescences will roll down and annihilate, and Arcady won't be able to collect them.In the second example Arcady will be able to collect 3 apples. First one is one initi...
PASSED
1,500
standard input
1 second
First line of input contains single integer number n (2 ≀ n ≀ 100 000) Β β€” number of inflorescences. Second line of input contains sequence of n - 1 integer numbers p2, p3, ..., pn (1 ≀ pi < i), where pi is number of inflorescence into which the apple from i-th inflorescence rolls down.
["1", "3", "4"]
#define e(n) for(i=1;i<=n;i++) n,p[1<<17],d[1<<17],s[1<<17],a,i; main(){ scanf("%d", &n); e(n-1)scanf("%d",&p[i+1]); e(n)s[d[i]=d[p[i]]+1]^=1; e(n)a+=s[i]; printf("%d",a); }
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.The current state of the wall can be respresented by a sequence $$$a$$$ of $$$n$$$ integers, with $$$a_i$$$ being the height...
Print "YES" if Vova can complete the wall using any amount of bricks (possibly zero). Print "NO" otherwise.
C
f73b832bbbfe688e378f3d693cfa23b8
6dcbdb369a9146568e4bf0cda936781b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation" ]
1545143700
["5\n2 1 1 2 5", "3\n4 5 3", "2\n10 10"]
NoteIn the first example Vova can put a brick on parts 2 and 3 to make the wall $$$[2, 2, 2, 2, 5]$$$ and then put 3 bricks on parts 1 and 2 and 3 bricks on parts 3 and 4 to make it $$$[5, 5, 5, 5, 5]$$$.In the second example Vova can put no bricks in the wall.In the third example the wall is already complete.
PASSED
2,200
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of parts in the wall. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) β€” the initial heights of the parts of the wall.
["YES", "NO", "YES"]
#include <stdio.h> #define N 200000 int main() { static int aa[N], ll[N], rr[N], stack[N]; int n, i, cnt; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &aa[i]); cnt = 0; for (i = 0; i < n; i++) { while (cnt && aa[stack[cnt - 1]] <= aa[i]) cnt--; ll[i] = cnt == 0 ? -1 : stack[cnt - 1]; stack[c...
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.The current state of the wall can be respresented by a sequence $$$a$$$ of $$$n$$$ integers, with $$$a_i$$$ being the height...
Print "YES" if Vova can complete the wall using any amount of bricks (possibly zero). Print "NO" otherwise.
C
f73b832bbbfe688e378f3d693cfa23b8
99cd0cd00a27180d0691009d619702e5
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "data structures", "implementation" ]
1545143700
["5\n2 1 1 2 5", "3\n4 5 3", "2\n10 10"]
NoteIn the first example Vova can put a brick on parts 2 and 3 to make the wall $$$[2, 2, 2, 2, 5]$$$ and then put 3 bricks on parts 1 and 2 and 3 bricks on parts 3 and 4 to make it $$$[5, 5, 5, 5, 5]$$$.In the second example Vova can put no bricks in the wall.In the third example the wall is already complete.
PASSED
2,200
standard input
2 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of parts in the wall. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) β€” the initial heights of the parts of the wall.
["YES", "NO", "YES"]
#include<stdio.h> #include<stdlib.h> struct node { int h; int flag; struct node *next; }; int main() { int n; struct node *list = NULL; scanf("%d", &n); int *a = (int *)malloc(sizeof(int) * n); for (int i = 0; i < n; ++i) { scanf("%d", a + i); while (list != NULL && a[i] > list->h) { if (list->flag) { ...
This is an easier version of the problem E with smaller constraints.Twilight Sparkle has received a new task from Princess Celestia. This time she asked to decipher the ancient scroll containing important knowledge of pony origin.To hide the crucial information from evil eyes, pony elders cast a spell on the scroll. Th...
Print one integer: the number of ways to get a version of the original from the scroll modulo $$$10^9+7$$$.
C
b27f6ae6fbad129758bba893f20b6df9
af4744a60eb8353e3fa28e7bd7979e0d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "dp", "hashing", "string suffix structures", "implementation", "strings" ]
1596810900
["3\nabcd\nzaza\nataka", "4\ndfs\nbfs\nsms\nmms", "3\nabc\nbcd\na", "6\nlapochka\nkartyshka\nbigbabytape\nmorgenshtern\nssshhhiiittt\nqueen"]
NoteNotice that the elders could have written an empty word (but they surely cast a spell on it so it holds a length $$$1$$$ now).
PASSED
2,800
standard input
1.5 seconds
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$): the number of words in the scroll. The $$$i$$$-th of the next $$$n$$$ lines contains a string consisting of lowercase English letters: the $$$i$$$-th word in the scroll. The length of each word is more or equal than $$$1$$$. The sum of lengths ...
["4", "8", "0", "2028"]
#include <stdio.h> #include <string.h> #define N 1000000 #define MD 1000000007 int main() { static char aa[N + 1]; static int dp[N + 1]; int k, n, i, ans; scanf("%d%s", &k, aa), n = strlen(aa); for (i = 0; i <= n; i++) dp[i] = 1; while (--k) { static char bb[N + 1], ok1[N], ok2[N]; static int dq[N + 1]; ...
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences o...
If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≀ k ≀ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≀ li ≀ |s|), which is the length of the i-th subsequence, and then li indices of days...
C
37b34461876af7f2e845417268b55ffa
23bd42d429e4f55f363133767f5b7e88
GNU C
standard output
512 megabytes
train_001.jsonl
[ "greedy" ]
1520583000
["0010100", "111"]
null
PASSED
1,600
standard input
1 second
In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.
["3\n3 1 3 4\n3 2 5 6\n1 7", "-1"]
//set many funcs template #include<stdio.h> #include<string.h> #include<stdlib.h> #include<stdbool.h> #include<time.h> #define inf 1072114514 #define llinf 4154118101919364364 #define mod 1000000007 #define pi 3.1415926535897932384 int max(int a,int b){if(a>b){return a;}return b;} int min(int a,int b){if(a<b){return a...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
1641c2b01b67eb006fa785f947f80e5a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int main() { int t; scanf("%d", &t); while (t--) { int n, k0, k1, k2, cnt; scanf("%d", &n); k0 = k1 = k2 = 0; while (n--) { int a; scanf("%d", &a); if (a % 3 == 0) k0++; else if (a % 3 == 1) k1++; else k2++; } cnt = k1 < k2 ? k1 : k2; printf("%d\n", k0...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
a1f8999827b7bcdb01ff78387e365b42
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int t, n, x, i; scanf("%d", &t); while(t--) { scanf("%d", &n); int p=0, q=0, r=0; for(i=0; i<n; i++) { scanf("%d", &x); if(x%3==0) { r++; } else if(x%3==1) { p++; } else { q++; } } if(p<=q) { printf("%d\n", r+p+((q-...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
391d165466cd5f84751ae00054e27d8c
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
ο»Ώ#include <stdio.h> int main() { unsigned long int x = 0; int t, n; scanf("%d", &t); int i, j; int three = 0, two = 0, one = 0; for (i = 0; i < t; i++) { scanf("%d", &n); for (j = 0; j < n; j++) { scanf("%d", &x); if (x % 3 == 0) three++; else if (x % 3 == 1) one++; else if (x % 3 == 2)...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
4e9b7d0a59e7d19492b819fdcff92465
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> #include <stdlib.h> int f[3]; int main(){ int q,n,a,i,j,nr,r,min; fscanf(stdin, "%d", &q); for(i=0;i<q;i++){ fscanf(stdin, "%d", &n); nr=0; f[0]=0; f[1]=0; f[2]=0; for(j=0;j<n;j++){ fscanf(stdin, "%d", &a); r=a%3; f[r]++; } nr=f[0]; min=f[1...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
21e31e1007f7cdaaccc7273686be6853
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main(){ long long int t,n,i,c=0,h=0,j=0; scanf("%lld",&t); while(t--) { scanf("%lld",&n); long long int kt, a[n]; for(i=0;i<n;i++) { scanf("%lld",&a[i]); a[i]=a[i]%3; if(a[i]==0) { c++; } if(a[i]==1) j++; if(a[i]==2) h++; } if(j>h){ kt=j-h; c=...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
dc3fb680eea2eb4b9e8bb6ef98f18376
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int main(){ int n,t,b[3],x,res; scanf("%d",&t); while(t--){ scanf("%d",&n); b[0]=0;b[1]=0;b[2]=0;res=0; while(n--){ scanf("%d",&x); b[x%3]++; } res+=b[0]; if(b[1]>b[2]){ res=res+b[2]+(b[1]-b[2])/3; } else{ res=res+b[1]+(b[2]-b[1])/3; } printf("%d\n",res); } }
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
fb2cf24ac5eab9052adadb24c191de79
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> #include <stdlib.h> #include <string.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int t,n,i,j,result=0, max, min, cnt1=0, cnt2=0; long int nb; scanf("%d",&t); for(i=0;i<t;i++){ scanf("%d",&n);...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
7097c30db0dbcff4e29c9dacfdfa8b65
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int main(void) { int x; scanf("%d",&x); // x is number of inputs while(x) { int y,i,count0=0,count1=0,count2=0,hm; // y is number of elements in input scanf("%d",&y); int a[y]; for(i=0;i<y;i++) { ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
b4e5b049c041f662c08f700d2799ef4f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int u,n,i; scanf("%d",&u); while(u>0) { int c=0,c1=0,c2=0; scanf("%d",&n); int a[n]; for(i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]%3==0) { c++; } if(a[i]%3==1) { c1++; } if(a[i]%3==2) { c2++; } } if(c1<c2) { c=c+c1; c2=c...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
86a0c05d4981ded972bd8221072f2fd8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int min(int a, int b) { return (a < b)? a : b; } int main() { int t, n; scanf("%d", &t); while(t--){ scanf("%d", &n); int remainder[3] = {0}; int x; int ans = 0; for(int i = 0; i < n; i++){ scanf("%d", &x); remainder[x%3]++; } int mn = min(remainder[1], remainder[2]); ans ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
68d6d5aa79f51f68bfd49dbd50785d3b
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int main(void) { int i,t,n,a[10000]; scanf("%d",&t); while(t--){ scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); int b=0,c=0,d=0; for(i=0;i<n;i++){ if(a[i]%3==1) c++; if(a[i]%3==2) d++; if(a[i]%3==0) b++; } if(c>d){ c=c-d; c=c/3; } ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
ee8a2dfb2fd94dadf4dddc787ce1944e
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> #include <stdlib.h> int main() { int n; scanf("%d",&n); while(n--){ int t; scanf("%d",&t); int a[t]; int i; for(i=0;i<t;i++){ scanf("%d",&a[i]); } int count=0; int count1=0; int count2=0; int coun...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
584bc02e56f3bcf5971e2cd3c908ecaa
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int t,a[100],n,cnt=0,r1=0,r2=0,p,q; scanf("%d",&t); while(t>0) {int cnt=0,r1=0,r2=0; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]%3==0) cnt++; else { if(a[i]%3==1) { ++r1; } else { ++r2; } } } if(r1>r2) ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
d28c7077fed6921eac58b0ad72f3a57a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int main(void) { int t = 0; scanf("%d", &t); while (t--) { int n = 0; int r = 0; scanf("%d", &n); int arr[n]; for (int i = 0, tmp; i < n; i++) { scanf("%d", &tmp); arr[i] = tmp % 3; } int j = 0; ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
8ce60c5d03a9ff2850ba90857b4d9cab
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int t,n,i,j,on,tw,thr; long long int a[102],p; scanf("%d",&t); for(i=0;i<t;i++) { on=0,tw=0,thr=0; scanf("%d",&n); for(j=0;j<n;j++) { scanf("%lld",&a[j]); ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
a3da6fe1f05218a51f2795bf56fad87d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> #define ll long long int n, a, t, ans, mod1, mod2; int min(int a, int b){ return (a>b)?b:a; } int main(){ scanf("%d", &t); while(t--){ scanf("%d", &n); ans = mod1 = mod2 = 0; for(int i = 1; i <= n; ++i){ scanf("%d", &a); if(a%3 == 1) mod1++; else if(a%3 == 2) mod2++; els...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
d881634b49c1acfea900ce86c49c14ed
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { long long int n,i,n1,c1=0,c2=0,c3=0,c,j; scanf("%I64d",&n); for(i=0;i<n;i++){ scanf("%I64d",&n1); long long int a[n1]; for(j=0;j<n1;j++){ scanf("%I64d",&a[j]); } for(j=0;j<n1;j++){ if(a[j]%3==0){ ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
d6675ca8613d4797cde92d1f06b1b172
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> #include<stdint.h> #include<inttypes.h> typedef int64_t i64; typedef int32_t i32; static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}} static i64 read_int(void){int prev='\0';int c=...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
56e7296ac4fc93363aa690ecf184a512
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int main() { int t; scanf("%d", &t); while(t--) { int n, a; scanf("%d", &n); int cnt[3] = {0}; for(int i = 0; i < n; ++i) { scanf("%d", &a); ++cnt[a % 3]; } int min = cnt[1]; if(min > cnt[2]) { mi...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
d6490c52198a7d367a7357ba4bfd2928
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> #define Min(a,b) a<b ? a : b int main() { int q; scanf("%d", &q); while(q--) { int n, k0=0, k1=0, k2=0, cnt; scanf("%d", &n); while (n--) { int a; scanf("%d", &a); if (a % 3 == 0) k0++; e...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
a7abb16eb769a2e2a78fbf3f4e4a01dc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main(){ int t; scanf("%d",&t); int count[3]; while(t--){ int n; scanf("%d",&n); int i; count[0]=0; count[1]=0; count[2]=0; for(i=0;i<n;i++){ int a; scanf("%d",&a); count[a%3]++; } ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
99b44cfbcdd391e41fe6ee95b6f5c83d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int t,n,array[105]; scanf("%d",&t); for(int i=0 ; i<t ;i++) { int a=0,b=0,c=0; scanf("%d",&n); for(int i=0 ; i<n ;i++) { scanf("%d",&array[i]); if(array[i]%3 == 0) ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
a44ce1d390204685df107f64dd376995
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int t, i, j; scanf("%d", &t); for(i = 0; i < t; i++) { int n, count1 = 0, count2 = 0, count = 0; scanf("%d", &n); int a[n]; for(j = 0; j < n; j++) { scanf("%d", &a[j]); if(a[j] % 3 == 0) { ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
4e4faa14e90cf3a370c7893000e1d6d8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> #include<math.h> int main(){ int m,n,i,j,d; while(~scanf("%d",&m)){ while(m--){ int k=0; d=0; j=0; scanf("%d",&n); while(n--){ scanf("%d",&i); if(i%3==1) j++; if(i%3==2) k++; ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
900fb55137e9ff354fc14812ef26bcf1
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> #include<string.h> int cnt[3]; int ans; void solve() { ans += cnt[0]; int min = cnt[1] < cnt[2] ? cnt[1] : cnt[2]; ans += min; cnt[1] -= min; cnt[2] -= min; if(cnt[1] || cnt[2]) { if(cnt[1]) { ans += cnt[1] / 3; } if(cnt[2]) { a...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
fb87b99d583809c8a50e24d52eec45df
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int t,i,j,n,a[101],count,p,q; scanf("%d",&t); for(i=1; i<=t; i++) { scanf("%d",&n); for(j=0; j<n; j++) { scanf("%d",&a[j]); } count=p=q=0; for(j=0; j<n; j++) { if(a[j]%3==0) c...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
7c4fbc63363651e6b1780e7aac81e747
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int t,n,i,b[3],s; scanf("%d",&t); while(t--){ scanf("%d",&n); for(i=0;i<3;i++) b[i]=0; long long int a; for(i=0;i<n;i++){ scanf("%lld",&a); b[a%3]++; } s=b[0]; if(b[1]>=b[2]){ s=s+b[2]; b[1]=b[1]-b[2]; s=s+b[1]/3; } else{ s=s+b[1]; b[2]=b[2]-b[1];...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
f6ae020a97fcd7a34258152ec5b6f488
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> #include <stdlib.h> int main() { int i,j,t,n,num,ans; int data1,data2,data3,max,min,rest; scanf("%d",&t); for(i=0;i<t;i++) { data1=0; data2=0; data3=0; ans=0; scanf("%d",&n); for(j=0;j<n;j++) { scanf("%d",&num); ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
4d0fe7e99497b30ee9a275e34eaf616f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int num; scanf("%d",&num); int total[num]; int a,b,d,e,i,n,ans; for(a=0; a<num; a++){ scanf("%d",&n); int ar[n]; for(b=0; b<n; b++){ scanf("%d",&ar[b]); } int c0,c1,c2; c0=0; c1=0; c2=0; for(b=0; b<n; b++){ i=ar[b]%3; if(i == 0) c0++; if(i == 1) ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
f68045dab7e7aa9baeca09fd1e17e9c7
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> #define rep(i,a,b) for (int i=a; i<b; i++) typedef long long ll; void scan(ll *arr, int length) { rep (i,0,length) scanf("%I64d",(arr+i)); scanf("\n"); } int min(int x, int y) { return (x<=y) ? x:y; } int maxmerge(ll *arr, int length) { int residue[]={0,0,0},aux; rep (i,0,length) ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
dd214da11ab4f3d2a9eb146340934fcc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int n,i,t,count,j,k,l; scanf("%d", &t); while(t--) { j=0; k=0; count=0; scanf(" %d", &n); for(i=0;i<n;i++) { scanf(" %d", &l); if(!(l%3)) count++; else if(l%3==1) j++; else k++;...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
31dd776c2738129a0d9eb78ab18ef21f
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int main(int argc, char** argv){ int q; scanf("%d", &q); for(int i = 0; i < q; i++){ int p; int nula = 0; int jedna = 0; int dva = 0; scanf("%d", &p); int digits[p]; for(int j = 0; j < p; j++){ int temp = 0; ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
98460dd8d8d6b103c111ab91e3ae64b7
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> #include<stdlib.h> main() { int q; scanf("%d",&q); while(q--) { int n,i; scanf("%d",&n); long int a[150],count=0,one=0,two=0; for(i=0;i<n;++i) { scanf("%ld",&a[i]); if(a[i]%3==0) { count++; } else { int n=a[i]%3; if(n==1) { one++; } else ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
14e0a57b6fbaf11edfdf963f37a32c12
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { long long int t,n,a[101],i,m,z,c,d; scanf("%lld",&t); for(m=1;m<=t;m++) { z=0; c=0; d=0; scanf("%lld",&n); for(i=1;i<=n;i++) {scanf("%lld",&a[i]); a[i]=a[i]%3; if(a[i]==0) {z++;} if(a[i]==1) {c++;}...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
878a52c281eccb4da2eac6beed32cecc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int n,i,j,sum=0,k1=0,k2=0,k3=0,y=0,x=0,count=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&x); for(j=0;j<x;j++) { scanf("%d",&y); if(y%3==0) { k1++; } else if(y%3==1) ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
60cdc8dc0f9d4f0af9b6c0c7fc8f905e
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n,cnt=0; scanf("%d",&n); int sup[3]={0}; for(int i=0;i<n;i++) { int a; scanf("%d",&a); sup[a%3]++; } cnt+=sup[0]; if(sup[1]>sup[2]) ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
9c8577c23a10662e2383224a5b1d89e8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int main() { int t,n; scanf("%d",&t); for (int u=1;u<=t;u++) { scanf("%d",&n); int a[n],count=0,c1=0,c2=0; //,sum[n*n]; //int pre[n*n]; for (int i=0;i<n;i++) { scanf("%d",&a[i]); } for (int i=0;i<n;i++) { if(a[i]%3==0) { count++; } else if(a[i]%3==1) { ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
c2ecc4b5c19581e76dd34c451748ec1a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include<stdio.h> #include<string.h> int main() { int t; scanf("%d",&t); while(t--) { int n,i,c=0,d=0,e=0; scanf("%d",&n); int a[n]; for(i=0;i<n;i++) { scanf("%d",&a[i]); a[i]%=3; if(a[i]==0) c++; if(a[i]==1) d++; ...
You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the f...
For each query print one integer in a single line β€” the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
C
e59cddb6c941b1d7556ee9c020701007
78f110cfdd4dd455e4f21e869ef2802a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "math" ]
1560090900
["2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2"]
NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, ...
PASSED
1,100
standard input
1 second
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) β€” the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).
["3\n3"]
#include <stdio.h> int main() { int q; scanf("%d", &q); for(int i = 0; i < q; i++) { int n; scanf("%d", &n); long long int array[n],count1 = 0,count2 = 0,ans = 0; for(int j = 0; j < n; j++) scanf("%lld", &array[j]); for(int j = 0; j < n; j++) { ...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
3a337cec3f87716aa125b2aa62427224
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
#include<stdio.h> #include<stdlib.h> #include<string.h> #define N 250000 int x[N][2]; int main(){ int a,b,c; scanf("%d%d",&a,&b); for(int w=0;w<a;w++){ scanf("%d%d",&x[w][0],&x[w][1]); } double lb = 0; double ub = 1e10; while((ub-lb)>= 1e-5){ double mid = (lb + ub)/2.0; double temp = mid; ...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
09a29f8d54ea3cab86737fd07a38d165
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
/* Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2). Problem C, by Abreto <m@abreto.net>. */ #include <stdio.h> #include <float.h> #define N (100001) #define EPS (1e-6) typedef long long int ll; int n = 0, p = 0; int a[N] = {0}; int b[N] = {0}; ll suma = 0; double dmax(double a, double b) { r...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
141040b96648436397b529e36477bafe
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
/* Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2). Problem C, by Abreto <m@abreto.net>. */ #include <stdio.h> #include <float.h> #define N (100001) #define EPS (1e-6) typedef long long int ll; int n = 0, p = 0; int a[N] = {0}; int b[N] = {0}; ll suma = 0; double dmax(double a, double b) { r...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
8f5b899cde76d2183fae4a609635668d
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
/* Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2). Problem C, by Abreto <m@abreto.net>. */ #include <stdio.h> #include <float.h> #define N (100001) #define EPS (1e-6) typedef long long int ll; int n = 0, p = 0; int a[N] = {0}; int b[N] = {0}; ll suma = 0; double dmax(double a, double b) { r...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
a51e83ec2017655b00767a22db7c3fcd
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
#include <stdio.h> #include <stdlib.h> #define N 100000 struct P { long long a, b; } pp[N]; int compare(const void *a, const void *b) { struct P *pa = (struct P *) a; struct P *pb = (struct P *) b; long long x = pa->b * pb->a; long long y = pb->b * pa->a; return x == y ? 0 : (x < y ? -1 : 1); } int main() { ...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
a680bdca2b937c29ed4e1c9475dea3d3
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
//Date:21-04-17 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<stdbool.h> #include<float.h> #include<math.h> #include<inttypes.h> #include<assert.h> #include<ctype.h> #include<limits.h> #include<time.h> #define ll long long #define For(i,n) for(i=0;i<n;i++) #define rep(i ,a ,b) for(i=(a);i<=(b);i++)...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
a6106c9837806cf59bc802b110ae8b25
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
//Date:21-04-17 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<stdbool.h> #include<float.h> #include<math.h> #include<inttypes.h> #include<assert.h> #include<ctype.h> #include<limits.h> #include<time.h> #define ll long long #define For(i,n) for(i=0;i<n;i++) #define rep(i ,a ,b) for(i=(a);i<=(b);i++)...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
0a2c10522d110c4e83fb0beb703af260
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> struct d { int a; int b; double time; long long int cavail; long long int creq; } dev[100010]; void maxheapify(struct d A[], int i, int n) { int l,r,largest; struct d temp; l = i*2+1; r = l+1; if (l<= n-1 && A[l].time > A[i].time)...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
2ad44761fd1709d7c091e47b9c172d9e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
#include<stdio.h> #include<stdlib.h> #define eps 0.0000000001 int dec[100009]={}, beg[100009]={}; int main() { int n,power,i; long long cnt=0; double left=0.0, right=1000000000000.0, totaltime, time; scanf("%d %d",&n,&power); for(i=1; i<=n; i++){ scanf("%d %d",&dec[i],&beg[i]); cnt += dec[i]; ...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
c3a5b68e24abb86e138eece6ef70fd0c
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
# include <stdio.h> # include <stdlib.h> struct store{ double a; double b; }; int compare(const void* i, const void* j){ struct store x = *((struct store*) i); struct store y = *((struct store*) j); if(x.a==y.a && x.b == y.b) return 1; if((x.b) / (x....
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
a0e58bd340551257fddd4085837aaab0
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
# include <stdio.h> # include <stdlib.h> struct store{ int index; double a; double b; }; int compare(const void* i, const void* j){ struct store x = *((struct store*) i); struct store y = *((struct store*) j); double r = (x.b) / (x.a) - (y.b) / (y.a)...
You have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power stored. All devices can store an arbitrary amount of power.You have a single...
If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits 0 power. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 4. Namely, let's assume that your answer is a and the answer of the jury is b. The checker prog...
C
1c2fc9449989d14d9eb02a390f36b7a6
7820a1d22bc76172e8564237dbf1e319
GNU C
standard output
256 megabytes
train_001.jsonl
[ "binary search", "math" ]
1492356900
["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1"]
NoteIn sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.In sample test 2, you can use the device indefinitely.In sample test 3, we can charge the third device for 2 / 5 of a second, then switch to char...
PASSED
1,800
standard input
2 seconds
The first line contains two integers, n and p (1 ≀ n ≀ 100 000, 1 ≀ p ≀ 109)Β β€” the number of devices and the power of the charger. This is followed by n lines which contain two integers each. Line i contains the integers ai and bi (1 ≀ ai, bi ≀ 100 000)Β β€” the power of the device and the amount of power stored in the de...
["2.0000000000", "-1", "0.5000000000"]
# include <stdio.h> # include <stdlib.h> struct store{ int index; double a; double b; double r; }; int compare(const void* i, const void* j){ struct store x = *((struct store*) i); struct store y = *((struct store*) j); double r = x.r - y.r; ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
cab28e89c3784c1b551821c3ab535795
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { int t,n,a[100005],i,arr[100005],l,r; scanf("%d",&t); while(t--) { scanf("%d",&n); l=0,r=-1; for(i=0;i<n;i++) { scanf("%d",&a[i]); } arr[++r]=a[0]; for(i=1;i<n-1;i++) { if((a[i]<a[i-1] && a[i]<a[i+1]) || (a[i]>a[i-1] && a[i...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
404fd10cb9b17aa235f7ed79597ae254
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int tc; scanf("%d",&tc); while(tc--){ int n,i,gt=0,sm=0,j,sum=0; scanf("%d",&n); int a[n],b[n]; for(i=0;i<n;i++) scanf("%d",&a[i]); b[0]=a[0]; for(i=1,j=1;i<n;i++){ if(a[i]>a[i-1]){ sm=0; if(gt==1) b[j-1]=a[i]; ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
ec39b723c34bcce00336ae40cf7754a8
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> int main() { int t; scanf("%d", &t); int n; int i; int p[100005]; int k; int s[100005]; for (; t > 0; t--) { scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &p[i]); s[0] = p[0]; s[1] = p[1]; k = 2; for (i = 2; i < n; i++) { if (p[0] > p[1]) { if (k % 2 > 0) ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
48f6e731caec111b8c3b2c7fecbfcfc1
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> #include <stdlib.h> int main() { long long int t; scanf("%lld", &t); do { long long int n; scanf("%lld", &n); long long int s[n]; long long int i; long long int visit[n]; for ( i = 0; i < n; ++i ) { scanf("%lld", &s[i]); visit[i] = 0; } long long int cnt = 2; visit...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
900f31b93af7f94c195e3044ceb45241
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int isprime(long long p) { int i; double max=sqrt(p); for(i=2;i<=max;i++) if(p%i==0)break; if(i>max && p!=1)return 1; return 0; } long long gcd(long long a,long long b) { long long i; for(i=a<b?a:b;i>0;i--) if((a%i==0...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
aa3840433b3c30e7fa3634ec079f41ac
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int a[n+1],ans[n+1],g=0,k=0; for(int i=0;i<n;i++) scanf("%d",&a[i]); if(a[1]>a[0]) g=1; else g=0; ans[k++]=a[0]; for(int i=1;...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
5614ce2ec63d19ec5ceeda69a4e1da63
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> int set_pos(int n) { if(n<0) return -1*n; else return n; } int main() { int t,n,a[100005],i,j,k,sub[100005],d1,d2; scanf("%d",&t); while(t--) { k=1; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&a[i]); sub[0]=a[0]; for(i=1;...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
5d7bcd9ee57e5a4e999c86f5df771fe2
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> int main() { //code int t; scanf("%d",&t); for(int i=0;i<t;i++) { int n; scanf("%d",&n); int a[n],r[n],count=0,j=1; long long int d[n-1]; for(int i=0;i<n;i++) { scanf("%d",&a[i]); } for(int i=0;i<n-1;i++) { d[i]=a[i+1]-a[i]; } ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
1e7487a4778ba18aaf944daf0c6d396a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> #include <stdlib.h> #define N 200009 int a[N]={0},b[N]={0}; int main() { int t,i; scanf("%d",&t); for(i=1;i<=t;i++){ int sum=0; int n; scanf("%d",&n); sum=n; int j; for(j=1;j<=n;j++){ int n1; scanf("%d",&n1); ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
8d27558a3cc579cbaaa5956ace602d22
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> #include<stdlib.h> int main() { int t,x,i,j,k,p,q,n; scanf("%d",&t); while(t--) { scanf("%d",&x); int n[x],a[x],b[x]; j=0; for(i=0;i<x;i++) { scanf("%d",&n[i]); if(i<=1) a[j++]=n[i]; else { ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
3beb40ac57856113c5c39c578cd9de05
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { // variable in description int T; int N; int X; int* P; // variable to support int* use; // variable to judge int i; int j; int k; scanf("%d",&T); for(i=0;i<T;i++) { scanf("%d",&N); P = (int*)malloc(sizeof(int)*...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
5ba7610cbd8815818fd8485d5385b368
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> int main() { int n, i, t, k; scanf("%d", &t); while(t--) { scanf("%d", &n); int a[n+1], b[n+1], y=0, r=1; for(i=0; i<n; i++) { scanf("%d", &a[i]); if(i==0) { b[i]=a[i]; } else { if(a[i]>a[i-1]) { if(y==1){ r++; } b[r]=a[i]; ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
c409f2307abfa49d5ea4ae7969054eff
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> int main() { int t, n, p[100000], out[100000], len, i; scanf("%d", &t); while (t--) { scanf("%d", &n); for (i=0; i<n; i++) scanf("%d", &p[i]); out[0] = p[0]; len = 1; for (i=1; i<n-1; i++) if ((p[i-1] < p[i] && p[i+1] < p[i]) || (p[i-1] > p[i] && p[i+1]...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
c94d595c9d159ec866b9f8e494517eca
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int t = 1; scanf("%d", &t); while(t--) { int n, id, x, xp, rlt[100010]; char sg; scanf("%d", &n); scanf("%d", &rlt[0]); scanf("%d", &rlt[1])...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
29cc4ec438b60357f75f830d6798340c
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> int main() { int t,n; scanf("%d",&t); for(int i=0;i<t;i++) { scanf("%d",&n); int ANS[100000]={},cnt=0,dir=0,pdir=0,pa,a; for(int o=0;o<n;o++) { scanf("%d",&a); if(o) { dir=a-pa; if(dir>0) { if(pdir<0) ANS[cnt++]=pa; pdir=1; } else if(dir<0) { ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
b2339d0bb1626c33306432956c2222ab
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> int main (void) { int t; scanf("%d",&t); while (t--) { int n,p=0; scanf("%d",&n); int A[n]; int B[n]; for (int i=0;i<n;i++) scanf("%d",&A[i]); B[p++]=A[0]; for (int i=1;i<n-1;i++) if ((A[i]>A[i+1] && A[i]>A[i-1]) || (A[i]<A[i+1] && A[i]<A[i-1])) B[p++]=A[i]; B[p++]=A[n-...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
658ee67c189dab207a52b84c21c00b5c
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int comparefunc (const void * a, const void * b) { return (*(int*)a)-(*(int*)b); } int main() { int i,j,m,n,t,k; scanf("%d", &t); for(i=0;i<t;i++){ scanf("%d", &n); //k=0; int a[n],b[n],len=2; for(j=0;j<n;j++)scan...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
6e2e099c76b207c3d1832aa7961a6d0a
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> int main(void) { int t = 0; scanf("%d", &t); while (t--) { int n = 0; scanf("%d", &n); int arr[n]; int res[n]; int tmp = 0; int r = 0; for (int i = 0; i < n; i++) { scanf("%d", arr + i); } res[r++] = ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
e049504ed7cb49cd8808cb5b2cce64d3
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> typedef float fl; typedef char ch; typedef long long ll; #define rep(i,a,n) for(i=a;i<n;i++) #define rev(i,n,a) for(i=n;i>=a;i--) #define repr(i,a,b) for(i=a;i<b;i++) #define s(n) scanf("%d",&n); #define s2(n,m) scanf("%d%d",&n,&m); #define s3...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
49cc3f6b1fd442ad4126c2b59bac41bc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int tc; scanf("%d",&tc); while(tc--){ int n,i,gt=0,sm=0,j,sum=0; scanf("%d",&n); int a[n],b[n]; for(i=0;i<n;i++) scanf("%d",&a[i]); b[0]=a[0]; for(i=1,j=1;i<n;i++){ if(a[i]>a[i-1]){ sm=0; if(gt==1) b[j-1]=a[i]; ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
5130c746282328852c005b2e828b20dd
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> int main (void) { int t; scanf("%d",&t); while (t--) { int n,p=0; scanf("%d",&n); int A[n]; int B[n]; for (int i=0;i<n;i++) scanf("%d",&A[i]); B[p++]=A[0]; for (int i=1;i<n-1;i++) if ((A[i]>A[i+1] && A[i]>A[i-1]) || (A[i]<A[i+1] && A[i]<A[i-1])) B[p++]=A[i]; B[p++]=A[n-...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
3aa6a5bb6a2a82688de0748d3bca843d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> int main(){int t,i,n,j,a[100000],b[100000],c; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%d",&n); for(j=0;j<n;j++) { scanf("%d",&a[j]); } b[0]=a[0]; c=1; for(j=1;j<n-1;j++) { if(a[j]>a[j-1]&&a[j]>a[j+1])...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
3de17b5ebed585fa2ac56160845450cc
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> int main() { long long int t,m,n,a[200002],i,s,k,l,x,b[200001]; scanf("%lld",&t); for(m=1;m<=t;m++) { s=0; l=1; k=0; scanf("%lld",&n); for(i=1;i<=n;i++) {scanf("%lld",&a[i]); b[i]=0; } i=1; b[1]=a[1]; while(i<n) { x=i;...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
d812675de321a44bf4c32497ec236ac5
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> int main() { int k,t; scanf ("%d",&t); for (k=0;k<t;k++) { int i,n,count=0; scanf ("%d",&n); int arr[n]; for (i=0;i<n;i++) scanf ("%d",&arr[i]); int raa[n]; raa[0]=arr[0]; for (i=1;i<n-1;i++) { if (((a...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
dd4f3354ca910290e12114564c932ed6
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> void main() { int test; scanf("%d",&test); while(test--) { int n,i,c=-1,d=0; scanf("%d",&n); int arr[n],brr[n]; for(i=0;i<n;i++) { scanf("%d",&arr[i]); brr[i]=0; if(d==0 && i>0) { if(arr[i-1] < arr[i]) {c=0; d=1; brr[0]=arr[i-1];} else if(arr[i-1] > arr[i]) {c=1; d=1; brr[0]=arr[i-1];} } } for(i=1;...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
d12fc0621585f902e6910887c3e9db66
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> int n,x; int check(int x){ if(x>0) return 1; else return 0; } int main() { long long int t,a[1000001],b[10000001],c[101]; scanf("%lld",&t); while(t--){ x=0; scanf("%lld",&n); scanf("%lld",&a[0]); b[0]=a[0]; for(int i=1;i<n;i++) { scanf("%lld",&a[i]); ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
a9071715a52e9d4757c2a1980286299d
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> int main() { int t; scanf("%d\n",&t); while(t--) { int n,i,j,b,c,e,f,g=0,h; scanf("%d\n",&n); int a[n],d[n]; for(i=0;i<n;i++) { scanf("%d ",&a[i]); d[i]=0; } for(i=1;i<n-1;i++) { b=abs(...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
0a738dc3ed0ecf980135596c56aaa5f7
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> int main(){ int t, n, i, flag = 0, j; int a[100001]; int b[100000]; scanf("%d", &t); while(t--){ flag = 0; j = 0; scanf("%d", &n); for(i = 0; i <= n; i++){ if(i < n) scanf("%d", &a[i]); if(i != 0){ if(a[i] > a[i - 1]){ if(flag == -1){ b[j++] = a[i - 1]; }...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
79d618420e755b302be3e588529551a9
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include<stdio.h> int main(){ int T, n,p[100000],i,j,flag,f,s[100000],k; scanf("%d", &T); while (T--) { scanf("%d", &n); for (i = 0,j=0,f=0;i < n;i++) { scanf("%d", &p[i]); if (i) { flag = p[i] > p[i - 1] ? 1 : -1; if (flag==f) { s[j-1] = p[i]; } else { s[j] = p[i]; j++; ...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
bccb1542dc0d67fb6bafdc14b7fe6c40
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 222222 typedef long long ll; ll tc, n, inp[N], prev, past, cnt; int main(){ scanf("%lld", &tc); while (tc--){ scanf("%lld%lld", &n, &inp[1]); cnt=n; for (int i=2; i<=n; i++) scanf("%lld", &inp[i]); p...
Given a permutation $$$p$$$ of length $$$n$$$, find its subsequence $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$ of length at least $$$2$$$ such that: $$$|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$$$ is as big as possible over all subsequences of $$$p$$$ with length at least $$$2$$$. Among all such subsequences, choos...
For each test case, the first line should contain the length of the found subsequence, $$$k$$$. The second line should contain $$$s_1$$$, $$$s_2$$$, $$$\ldots$$$, $$$s_k$$$Β β€” its elements. If multiple subsequences satisfy these conditions, you are allowed to find any of them.
C
857de33d75daee460206079fa2c15814
1e8ac43b14d58df97b296d4e18757589
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "two pointers", "greedy" ]
1592060700
["2\n3\n3 2 1\n4\n1 3 4 2"]
NoteIn the first test case, there are $$$4$$$ subsequences of length at least $$$2$$$: $$$[3,2]$$$ which gives us $$$|3-2|=1$$$. $$$[3,1]$$$ which gives us $$$|3-1|=2$$$. $$$[2,1]$$$ which gives us $$$|2-1|=1$$$. $$$[3,2,1]$$$ which gives us $$$|3-2|+|2-1|=2$$$. So the answer is either $$$[3,1]$$$ or $$$[3,2,1]$$$....
PASSED
1,300
standard input
1 second
The first line contains an integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$)Β β€” the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$)Β β€” the length of the permutation $$$p$$$. The second line of each test case contains $$$...
["2\n3 1 \n3\n1 4 2"]
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int t,i; scanf("%d",&t); for(i=0;i<t;i++) { int n; scanf("%d",&n); int p[n],j,a[n],k=2; for(j=0;j<n;j++) { scanf("%d",(p+j)); } for(j...
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.Let's consider a rectangular image that is represented...
Print a single number β€” the minimum number of operations that you need to make to calculate the value of the feature.
C
ce6b65ca755d2d860fb76688b3d775db
427cdc77186aed0558bac42dc34bb0a9
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "greedy" ]
1433595600
["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW"]
NoteThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations: add the sum of pixels i...
PASSED
1,900
standard input
1 second
The first line contains two space-separated integers n and m (1 ≀ n, m ≀ 100) β€” the number of rows and columns in the feature. Next n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to "W", if this element of the feature is white and "B" if it...
["2", "4", "3", "4"]
#include <stdio.h> char feature[100][101]; int field[100][100]; int main(void) { int i, j, k, l; int n, m; int ans; scanf("%d %d", &n, &m); for (i = 0; i < n; i++) scanf("%s", feature[i]); for (i = 0; i < n; i++) for (j = 0; j < m; j++) feature[i][j] = feature[i][j...
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.Let's consider a rectangular image that is represented...
Print a single number β€” the minimum number of operations that you need to make to calculate the value of the feature.
C
ce6b65ca755d2d860fb76688b3d775db
54a5855c3d5a887c1c49301c73f49178
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "greedy" ]
1433595600
["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW"]
NoteThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations: add the sum of pixels i...
PASSED
1,900
standard input
1 second
The first line contains two space-separated integers n and m (1 ≀ n, m ≀ 100) β€” the number of rows and columns in the feature. Next n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to "W", if this element of the feature is white and "B" if it...
["2", "4", "3", "4"]
#include <stdio.h> #define MAXN 102 #define min(__a, __b) ((__a) < (__b) ? (__a) : (__b)) char f[MAXN][MAXN]; int a[MAXN][MAXN] = {{0}}; int ans = 0; int i, j; void add(int n, int m, int delta) { for (i = 0; i < n; ++i) for (j = 0; j < m; ++j) a[i][j] += delta; } void solve(int n, int m) { if (!m || ...
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.Let's consider a rectangular image that is represented...
Print a single number β€” the minimum number of operations that you need to make to calculate the value of the feature.
C
ce6b65ca755d2d860fb76688b3d775db
6bd1a1d5f1f23ee76733ccebbf3b8512
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "greedy" ]
1433595600
["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW"]
NoteThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations: add the sum of pixels i...
PASSED
1,900
standard input
1 second
The first line contains two space-separated integers n and m (1 ≀ n, m ≀ 100) β€” the number of rows and columns in the feature. Next n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to "W", if this element of the feature is white and "B" if it...
["2", "4", "3", "4"]
/*Haar Features*/ #include<stdio.h> char feature[105][105]; int arr[105][105]; int main() { int count, i, j, k, l, m, n, val; scanf("%d %d", &n, &m); for (i = 0; i < n; i++) scanf("%s", feature[i]); for (i = 0; i < n; i++) for (j = 0; j < m; j++) arr[i][j] = 0; count = 0; for (i = n - 1; i >= 0; i--) {...
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.Let's consider a rectangular image that is represented...
Print a single number β€” the minimum number of operations that you need to make to calculate the value of the feature.
C
ce6b65ca755d2d860fb76688b3d775db
cdf29e9e8defc4f3e4c39d92532d0117
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "greedy" ]
1433595600
["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW"]
NoteThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations: add the sum of pixels i...
PASSED
1,900
standard input
1 second
The first line contains two space-separated integers n and m (1 ≀ n, m ≀ 100) β€” the number of rows and columns in the feature. Next n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to "W", if this element of the feature is white and "B" if it...
["2", "4", "3", "4"]
#include<stdio.h> int main() { int n,m; char input[100][101]; scanf("%d%d",&n,&m); int i,j; for(i=0;i<n;i++) scanf("%s",input[i]); int trans[100][100]={0}; int c=0; for(i=n-1;i>=0;i--) for(j=m-1;j>=0;j--) { int tmp; if(input[i][j]=='W') tmp=1-trans[i][j]; else tmp=-1-trans[i][j]; ...
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.Let's consider a rectangular image that is represented...
Print a single number β€” the minimum number of operations that you need to make to calculate the value of the feature.
C
ce6b65ca755d2d860fb76688b3d775db
f28aa90ac05002f8da4dbc2918dd92f1
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "greedy" ]
1433595600
["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW"]
NoteThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations: add the sum of pixels i...
PASSED
1,900
standard input
1 second
The first line contains two space-separated integers n and m (1 ≀ n, m ≀ 100) β€” the number of rows and columns in the feature. Next n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to "W", if this element of the feature is white and "B" if it...
["2", "4", "3", "4"]
# include <stdio.h> int r=0,c,m,n; int value[100][101]; char colour[100][101]; void detect_annomaly() { for(r=m-1;r>=0;r--) for(c=n-1;c>=0;c--) { if(colour[r][c]=='W' && value[r][c]!=1) return; if(colour[r][c]=='B' && value[r][c]!=-1) return; } r=-1; } void change_value() { int i,j; int add=valu...
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.Let's consider a rectangular image that is represented...
Print a single number β€” the minimum number of operations that you need to make to calculate the value of the feature.
C
ce6b65ca755d2d860fb76688b3d775db
c78cdea82c843883be9973f4b46a3e1e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "greedy" ]
1433595600
["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW"]
NoteThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations: add the sum of pixels i...
PASSED
1,900
standard input
1 second
The first line contains two space-separated integers n and m (1 ≀ n, m ≀ 100) β€” the number of rows and columns in the feature. Next n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to "W", if this element of the feature is white and "B" if it...
["2", "4", "3", "4"]
#include <stdio.h> int tab[100][100]; int sol[100][100]; int swap[100][100]; int visited[100][100]; void solve2(int n, int m) { if (sol[n][m] != tab[n][m]) { int d = sol[n][m] - tab[n][m]; swap[n][m] = 1; int i, j; for (i = 0; i <= n; i++) { for (j = 0; j <= m; j++) { sol[i][j] -= d; } } } } st...
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.Let's consider a rectangular image that is represented...
Print a single number β€” the minimum number of operations that you need to make to calculate the value of the feature.
C
ce6b65ca755d2d860fb76688b3d775db
b64b88bf8493ec2041ea2c93a5e44388
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "greedy" ]
1433595600
["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW"]
NoteThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations: add the sum of pixels i...
PASSED
1,900
standard input
1 second
The first line contains two space-separated integers n and m (1 ≀ n, m ≀ 100) β€” the number of rows and columns in the feature. Next n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to "W", if this element of the feature is white and "B" if it...
["2", "4", "3", "4"]
#include<stdio.h> #include<stdlib.h> int main() { int n,m,i,j,x,y,count=1,initial[100][100]={0},diff,final[100][100]; /////// int u,v; ///////// char final2[100][101]; scanf("%d %d",&n,&m); for(i=0;i<n;i++) { scanf(" %s",&final2[i][0]); for(j=0;j<m;j++) if(fin...
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.Let's consider a rectangular image that is represented...
Print a single number β€” the minimum number of operations that you need to make to calculate the value of the feature.
C
ce6b65ca755d2d860fb76688b3d775db
f669a2ab9b1dc7643d05643ed263a966
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "greedy" ]
1433595600
["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW"]
NoteThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations: add the sum of pixels i...
PASSED
1,900
standard input
1 second
The first line contains two space-separated integers n and m (1 ≀ n, m ≀ 100) β€” the number of rows and columns in the feature. Next n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to "W", if this element of the feature is white and "B" if it...
["2", "4", "3", "4"]
#include<stdio.h> char grid[102][102]; int valuegrid[102][102], a[102][102] = {0}; int main() { int i, j, diff, n, m, ans = 0, x, y; scanf("%d%d", &n, &m); for(i = 0; i < n; i++){ scanf("%s", grid[i]); } for(i = 0 ; i < n; i++){ for(j = 0; j <...
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.Let's consider a rectangular image that is represented...
Print a single number β€” the minimum number of operations that you need to make to calculate the value of the feature.
C
ce6b65ca755d2d860fb76688b3d775db
b65ffa5d0bc2b79abfeb9aafb8bd9f6e
GNU C
standard output
256 megabytes
train_001.jsonl
[ "implementation", "greedy" ]
1433595600
["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW"]
NoteThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations: add the sum of pixels i...
PASSED
1,900
standard input
1 second
The first line contains two space-separated integers n and m (1 ≀ n, m ≀ 100) β€” the number of rows and columns in the feature. Next n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to "W", if this element of the feature is white and "B" if it...
["2", "4", "3", "4"]
#include<stdio.h> int main() { int n, m, i, j, num, M[100][100], x; char s[100][101]; scanf("%d %d", &n, &m); for(i = 0; i < n; i++) { scanf("%s", s[i]); for(j = 0; j < m; j++) { M[i][j] = 0; } } num = 0; x = 0; for(j = m - 1; j >= 0; j--) { M[n - 1][j] += x; if(s[n - 1][j] == 'W' && M[n - 1][j] !=...
Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1, a2, ..., an.While Vasya was walking, his little brother Stepan played with Vasya's cubes and change...
Print "LIE" (without quotes) if it is guaranteed that Stepan deceived his brother. In the other case, print "TRUTH" (without quotes).
C
1951bf085050c7e32fcf713132b30605
18579c6c56bfd873a2dfb5ab2ac3c575
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "sortings", "implementation", "*special" ]
1491406500
["5 2 4\n3 4 2 3 1\n3 2 3 4 1", "3 1 2\n1 2 3\n3 1 2", "4 2 4\n1 1 1 1\n1 1 1 1"]
NoteIn the first example there is a situation when Stepan said the truth. Initially the sequence of integers on the cubes was equal to [3, 4, 2, 3, 1]. Stepan could at first swap cubes on positions 2 and 3 (after that the sequence of integers on cubes became equal to [3, 2, 4, 3, 1]), and then swap cubes in positions 3...
PASSED
1,500
standard input
2 seconds
The first line contains three integers n, l, r (1 ≀ n ≀ 105, 1 ≀ l ≀ r ≀ n) β€” the number of Vasya's cubes and the positions told by Stepan. The second line contains the sequence a1, a2, ..., an (1 ≀ ai ≀ n) β€” the sequence of integers written on cubes in the Vasya's order. The third line contains the sequence b1, b2, .....
["TRUTH", "LIE", "TRUTH"]
#include<stdio.h> #include<stdlib.h> int main (){ int n=0,l=0,r=0; scanf("%d %d %d",&n,&l,&r); int a[n+1]; int b[n+1]; int dp1[100001]; int dp2[100001]; int i; for(int i=0;i<=100000;i++) { dp1[i]=0; dp2[i]=0; } for( i=1;i<=n;i++) { scanf("%d",&a[i]); if(i>=l && i<=r) dp1[a[i]]++; } ...
Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1, a2, ..., an.While Vasya was walking, his little brother Stepan played with Vasya's cubes and change...
Print "LIE" (without quotes) if it is guaranteed that Stepan deceived his brother. In the other case, print "TRUTH" (without quotes).
C
1951bf085050c7e32fcf713132b30605
63e240ac5347dc82697b3b0b82cd9416
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "sortings", "implementation", "*special" ]
1491406500
["5 2 4\n3 4 2 3 1\n3 2 3 4 1", "3 1 2\n1 2 3\n3 1 2", "4 2 4\n1 1 1 1\n1 1 1 1"]
NoteIn the first example there is a situation when Stepan said the truth. Initially the sequence of integers on the cubes was equal to [3, 4, 2, 3, 1]. Stepan could at first swap cubes on positions 2 and 3 (after that the sequence of integers on cubes became equal to [3, 2, 4, 3, 1]), and then swap cubes in positions 3...
PASSED
1,500
standard input
2 seconds
The first line contains three integers n, l, r (1 ≀ n ≀ 105, 1 ≀ l ≀ r ≀ n) β€” the number of Vasya's cubes and the positions told by Stepan. The second line contains the sequence a1, a2, ..., an (1 ≀ ai ≀ n) β€” the sequence of integers written on cubes in the Vasya's order. The third line contains the sequence b1, b2, .....
["TRUTH", "LIE", "TRUTH"]
#include <stdio.h> #include <stdlib.h> int A[100005], B[100005], C[100005]; void merge(int A[],int I,int F,int aux[]) { int piv=(I+F)/2; int p=I,q=piv+1; int r=I; while(p<=piv && q<=F) { if(A[p]<=A[q]) aux[r++]=A[p++]; else aux[r++]=A[q++]; } if(p<=piv) for(int i=p;i<=piv;i++) aux[r++]=A[i]; if...
Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1, a2, ..., an.While Vasya was walking, his little brother Stepan played with Vasya's cubes and change...
Print "LIE" (without quotes) if it is guaranteed that Stepan deceived his brother. In the other case, print "TRUTH" (without quotes).
C
1951bf085050c7e32fcf713132b30605
fe893591251665650eab031a0fe96ff6
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "sortings", "implementation", "*special" ]
1491406500
["5 2 4\n3 4 2 3 1\n3 2 3 4 1", "3 1 2\n1 2 3\n3 1 2", "4 2 4\n1 1 1 1\n1 1 1 1"]
NoteIn the first example there is a situation when Stepan said the truth. Initially the sequence of integers on the cubes was equal to [3, 4, 2, 3, 1]. Stepan could at first swap cubes on positions 2 and 3 (after that the sequence of integers on cubes became equal to [3, 2, 4, 3, 1]), and then swap cubes in positions 3...
PASSED
1,500
standard input
2 seconds
The first line contains three integers n, l, r (1 ≀ n ≀ 105, 1 ≀ l ≀ r ≀ n) β€” the number of Vasya's cubes and the positions told by Stepan. The second line contains the sequence a1, a2, ..., an (1 ≀ ai ≀ n) β€” the sequence of integers written on cubes in the Vasya's order. The third line contains the sequence b1, b2, .....
["TRUTH", "LIE", "TRUTH"]
#include <stdio.h> #define ri(x) scanf("%d", &x) #define rii(x,y) scanf("%d%d", &x, &y) #define FOR(i,S,E) for(int i=S; i<E; i++) #define pb push_back #define fst first #define snd second #define mp make_pair int a[100005]; int main () { int n,l,r; rii(n,l); ri(r); l--; r--; FOR(i,0,n) { ri(a[i]); } FOR(i,0,n...
Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1, a2, ..., an.While Vasya was walking, his little brother Stepan played with Vasya's cubes and change...
Print "LIE" (without quotes) if it is guaranteed that Stepan deceived his brother. In the other case, print "TRUTH" (without quotes).
C
1951bf085050c7e32fcf713132b30605
e14c43e1ccd718617373cb6956f7b4da
GNU C11
standard output
256 megabytes
train_001.jsonl
[ "sortings", "implementation", "*special" ]
1491406500
["5 2 4\n3 4 2 3 1\n3 2 3 4 1", "3 1 2\n1 2 3\n3 1 2", "4 2 4\n1 1 1 1\n1 1 1 1"]
NoteIn the first example there is a situation when Stepan said the truth. Initially the sequence of integers on the cubes was equal to [3, 4, 2, 3, 1]. Stepan could at first swap cubes on positions 2 and 3 (after that the sequence of integers on cubes became equal to [3, 2, 4, 3, 1]), and then swap cubes in positions 3...
PASSED
1,500
standard input
2 seconds
The first line contains three integers n, l, r (1 ≀ n ≀ 105, 1 ≀ l ≀ r ≀ n) β€” the number of Vasya's cubes and the positions told by Stepan. The second line contains the sequence a1, a2, ..., an (1 ≀ ai ≀ n) β€” the sequence of integers written on cubes in the Vasya's order. The third line contains the sequence b1, b2, .....
["TRUTH", "LIE", "TRUTH"]
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/ #include<stdio.h> #include<stdlib.h> #define opt std::ios_base::sync_with_stdio(false) #define I int #define li int32_t #define lli long long #define ulli unsigned long long #define pn printf("\n") #define nl cout<<'\n' #define sf(N) scan...