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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | c27b97ebd768c3118167c5232fd96c85 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<string.h>
int a[26];
int main()
{
int k;
scanf("%d",&k);
char s[1001];
scanf("%s",s);
int i=0,j=0;
int n=strlen(s);
for(i=0;i<n;i++)
a[s[i]-'a']++;
// printf("%d\n\n",a[25]);
for(i=0;i<26;i++)
{
if(a[i]%k!=0)
{
printf("-1\n");
return 0;
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | f60eca9d91df7734cd6bb9ebbbfa7dd5 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<string.h>
#include<stdio.h>
main()
{
int k,x,a[27]={0},g,t,y,j=0;
char s[1001],b[1001];
scanf("%d%s",&k,s);
g=strlen(s);
if(g%k==0)
{
t=g/k;
for(x=0;x<g;x++)
a[s[x]-96]++;
for(x=1;x<=26;x++)
{
if(a[x]%k==0)
{
for(y=1;y<=a[x]/k;y++)
b[j++]=(char)(96+x);
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 0f52033db2e3ce1e69dc9d45055b9e1b | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
char s[1001];
int n;
scanf("%d ",&n);
gets(s);
int arr[26]={0};
int i;
for(i=0;i<strlen(s);i++){
int y=s[i];
arr[y-97]++;
}
int j;
int numL;
for(i=0;i<26;i++){
if(!(arr[i]%n==0||arr[i]==0)){
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 326c1f5506569b6447e8ad49292021c2 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<string.h>
int main()
{int i,j,k,n,m,t,b[26]={0};char a[1005]={'\0'},c[1005]={'\0'},d[1005]={'\0'};
scanf("%d",&n);
scanf("%s",a);
t=strlen(a);
for(i=0;i<t;i++)
{k=a[i];m=k-97;
b[m]++;
}j=0;
for(i=0;i<26;i++)
{
if(b[i]<n&&b[i]!=0)
{printf("-1");goto flag;}
else
{if(b[i]!=0)
{while(b[i]>0)
{c[... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 7641fbba163589fd8eac54b8042d7b24 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | int main() {
char s[1010];
int freq[26]={0};
int k;
int i,j,l;
scanf("%d", &k);
scanf(" %s", s);
for( i = 0; s[i] != '\0'; i++) freq[s[i]-'a']++;
for( i = 0; i < 26; i++)
if(freq[i]%k != 0) {
printf("-1\n");
return 0;
}
for( i = 1; i <= k; ... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 224fb17a4bdc0e9d9e2047e663a49817 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include <stdio.h>
int main()
{
int k, i, let[26] = { 0 };
char s[1001];
scanf ("%d %s", &k, s);
for (i = 0; s[i]; i++)
let[s[i] - 'a']++;
for (i = 0; i < 26 && let[i] % k == 0; i++)
let[i] /= k;
if (i < 26)
printf ("-1");
else {
while (k--) {
for (i = 0; i < 26; i++)
if (let[i] > 0) {
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 7e1c4ca687880a28e8f7888a856593d4 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<string.h>
int main()
{
char s[1001],a[1001];
int coun[1001];
int i,j,k,x,y,count,n=0,c=0,m=0,co;
scanf("%d",&k);
scanf("%s",&s);
x=strlen(s);
for(i=0;i<x;i++)
{
c=0;
count=0;
for(y=0;y<n;y++)
{
if(s[i]!=a[y])
c... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 4f61feeac3f380488080382a109e55c6 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<string.h>
#include<stdio.h>
int main () {
int x,i,h[1006],f=1,j,diz=0;
char d[1006],cvp[1006];
scanf("%d %s",&x,d);
for(i=0;i<strlen(d);i++)
h[d[i]-'a']++;
for(i=0;i<26;i++){
if(h[i]){
if(!(h[i]%x)){
for(j=0;j<h[i]/x;j++){
cvp[diz]=i+'a';
diz++;}}
else{ printf("-1");
return 0;}}}
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 73a26e55419c5fbf990df9dddf192773 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | main () {
int x,i,h[1006],f=1,j,diz=0;
char d[1006],cvp[1006];
scanf("%d %s",&x,d);
for(i=0;i<strlen(d);i++)
h[d[i]-'a']++;
for(i=0;i<26;i++){
if(h[i]){
if(!(h[i]%x)){
for(j=0;j<h[i]/x;j++){
cvp[diz]=i+'a';
diz++;}}
else{ printf("-1");
return 0;}}}
for(i=0;i<x;i++)
for(j=0;j<diz;j++)
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | d728dd4bc2b14d3e854fbbe878da7945 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include <stdio.h>
int A[150], B[150];
int main()
{
char i;
int k;
char str[1001];
scanf("%d", &k);
getchar();
gets(str);
for (i = 0; i < strlen(str); i++)
A[str[i]]++;
for (i = 'a'; i <= 'z'; i++)
if (A[i] % k)
{
printf("-1");
return 0;
}
else
B[i] = A[i] / k;
while (1)
{
int check =... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | d89a12161d3bbe1ab65fae7aa5cf36a7 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include <stdio.h>
char s[1010];
int n, a[26],i,j,k;
int main ( ) {
scanf ( "%d%s", &n, s );
for ( i = 0; s[i]; ++i ) ++a[s[i] - 'a'];
for ( i = 0; i < 26; ++i ) {
if ( a[i] % n ) {
printf ( "-1\n" );
return 0;
}
}
for ( i = 1; i <= n; ++i )
for ... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 21f7fb08cf918d0c096178a586231210 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<string.h>
#include<stdio.h>
int main()
{
int k,x,a[27]={0},g,t,y,j=0;
char s[1001],b[1001];
scanf("%d%s",&k,s);
g=strlen(s);
if(g%k==0)
{
t=g/k;
for(x=0;x<g;x++)
a[s[x]-96]++;
for(x=1;x<=26;x++)
{
if(a[x]%k==0)
{
for(y=1;y<=a[x]/k;y++)
b[j++]=(char)(96+x);
}
else
goto... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | c9dcc2072ce90827152a605ae4ae5db8 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
int main()
{
int i,j,k,a[26]={0},l,flag=0,cnt=0;
char s[1011],b[100];
scanf("%d",&k);
scanf("%s",s);
for(i=0;s[i]!='\0';i++)
{
a[s[i]-97]++;
}
for(i=0;i<26;i++)
{
if(a[i]>0)
{
if(a[i]%k==0)
{
l=a[i]/k;
for(j=0;j<l;j++){
b[cnt]=i+97;
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 0d20112a2032cb4dd0d41203d2566bae | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include <stdio.h>
int s[26];
int main() {
//printf("%d", 'z'-('a'-1));//26
int k;
scanf("%d\n", &k);
char c; int len=0;
while((c = getchar()) != EOF && c != '\n') {
//printf("'%c'\n", c);
s[c-'a']++;
++len;
}
int i;
for(i=0; i<26; i++)
if(!(s[i] == 0 || s[i] % k == 0)) {
puts("-1");
return 0;
}... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | f3c75b699346bafa1585f7a6ece694eb | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<math.h>
#include<ctype.h>
#include<string.h>
#define getchar getchar//_unlocked
#define M 1000000007
int getint ()
{
int n=0;
char ch=getchar();
while(ch<'0' || ch>'9')
ch=getchar();
while(ch>='0' && ch<='9')
{
n=n*10+ch-... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | e60079a210db373f21d1cdeef0bf716e | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | int main()
{
int a[256]={0},k,n,l=0,ll;
char ans[1000]={""};
scanf("%i",&n); getchar();
while((k=getchar())!='\n')a[k]++;
for(k='a';k<='z';k++){
if(a[k]%n){puts("-1");return 0;}
ll=a[k]/n;
while(ll--)ans[l++]=k;
}
while(n--)printf("%s",ans);
} | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | e3a0b9701647937592db6ef5cb129ab5 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<string.h>
int main()
{
int n;
scanf("%d",&n);
char s[1005];
scanf("%s",s);
int a[150]={0},i=0;
char *p=s;
while(*p) {
a[*p]++;
p++;
}
int c=0,flag=0;
char b[1005];
int k=0;
for(i=97;i<=122;i++) {
if(a[i]) {
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 1d13ef594bcc61e4b984250dad0b50a1 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#define MAXLEN 101000
int main()
{
char buf[MAXLEN];
int k;
int i,j;
int counts[30];
int bufIndex;
while( scanf("%d",&k) != EOF )
{
getchar();
gets(buf);
memset(counts,0,sizeof(counts));
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 1b4cf632e50d9c419125b9ed6bc428d8 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include <stdio.h>
#include <string.h>
int main()
{
int a, b, c, d;
int ZB[26];
char ZA[1001], ZC[1001];
scanf("%d%s", &a, ZA);
if (a == 1) {
printf("%s\n", ZA);
} else if (strlen(ZA) % a == 0) {
for (b = 0; b < 26; ZB[b++] = 0);
for (b = 0; ZA[b]; ++b)
ZB[ZA[b] - 'a'] += 1;
c = 0;
for (b = 0; b <... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 76454e9d154ae09c8c5b584b54ae3e3d | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
int main()
{
int i,n,j,k,x;
char a[10000];
int f[26];
for(i=0;i<26;i++)
f[i]=0;
scanf("%d %s",&n,a);
for(i=0;a[i]!=0;i++)
f[a[i]-'a']++;
for(i=0;i<26;i++)
{
if(f[i]==0 || f[i]%n == 0)
continue;
break;
}
if(i<26)
printf("-1\n");
else
{
for(i=0;i<26;i++)
{
if(f[i])
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 09e2fa203f8c5f0bb403803417a4ed33 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
int main()
{
int m=1,k,n,p=0,i=0,c,l[26]={0},j;
char s[1000];
scanf("%d\n",&n);
while((c=getchar())!='\n')
{s[i++]=c;
++l[c-'a'];
}
for(j=0;j<i;j++)
{
k=s[j]-'a';
if(l[k]<n&&n!=1||(l[k]%n))
{m=0;break;}}
if(m)
{for(i=0;i<n;i++)
{for(c=0;c<26;c++)
if(l[c])
for(j=0;j<l[c]/n;j++)
printf("%c",c+'a');
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 2616181d7f14853865efb69eaf6e2dac | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
int main()
{
int k,i,j;
scanf("%d",&k);
char s[1003],s1[1003];
scanf("%s",s);
int a[26];
for(i=0;i<26;i++)
a[i]=0;
int l=strlen(s);int f=0,m;
for(i=0;i<l;i++)
{
a[s[i]-97]++;
}
for(i=0;i<26;i++)
{
if(a[i]%k!=0)
{
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 1cc798c3f95c42c62afdfeac001f569d | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<string.h>
int main(){
int x,i,j,k;
scanf("%d",&x);
char s[1001];
scanf("%s",s);
int arr[26];
for(i=0;i<26;i++){
arr[i]=0;
}
for(i=0;i<strlen(s);i++){
arr[s[i]-97]++;
}
for(i=0;i<26;i++){
if(arr[i]%x==0){
continue;
}
else{
prin... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 2b6fe8fe513466a02ff807117430cd99 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include <stdio.h>
#include <string.h>
int main() {
int k,count[26]={0};
scanf("%d",&k);
char a[1000];
scanf("%s",a);
int l=strlen(a);
char nava[l/k];
int ind=0,i,j;
for(i=0;a[i]!='\0';i++)
count[a[i]-'a']++;
for(i=0;i<26;i++)
{
if(count[i]%k!=0)
{
printf("-1");
return 0;
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | 0c71665168f01d1fa7ff2b42cf32aa49 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<string.h>
main()
{
int n,i,j,k,m,b,a;
int x[26];
scanf("%d",&n);
char y[1000];
scanf("%s",&y);
for(i=0;i<26;i++)
{
x[i]=0;
}
for(i=0;i<strlen(y);i++)
{
j=y[i]-'a';
x[j]++;
}
for(i=0;i<26;i++)
{
if(x[i]%n!=0)
... | |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, co... | Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes). | C | f5451b19cf835b1cb154253fbe4ea6df | b4d1204e138a910bce8360ba6e01062f | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"strings"
] | 1346081400 | ["2\naazz", "3\nabcabcabz"] | null | PASSED | 1,000 | standard input | 2 seconds | The first input line contains integer k (1ββ€βkββ€β1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1ββ€β|s|ββ€β1000, where |s| is the length of string s. | ["azaz", "-1"] | #include<stdio.h>
#include<string.h>
int arr[26],c;
char ans[1000007];
int main ()
{
int n,i,j;
char s[1000007];
scanf("%d",&n);
getchar();
gets(s);
int len=strlen(s);
for(i=0; i<len; i++)
arr[s[i]-'a']++;
for(i=0; i<26; i++)
{
if(arr[i]%n!=0)
{
pr... | |
You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | C | a4849505bca48b408a5e8fb5aebf5cb6 | 610f6533fac7102493c4452e11bf09fd | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"graphs"
] | 1530628500 | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | null | PASSED | 2,100 | standard input | 4 seconds | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | #include<stdio.h>
#include<stdlib.h>
#define MAXVERS 500000
typedef struct Edge{
int adjver;
int isVisited;
struct Edge *next;
}Edge;
typedef struct Vertex{
int degree;
int dist; // the distence between the vertex and the nearest end of diameter.
struct Edge *edgelist;
}Vertex;
Vertex vertex[MAXVERS];
int nV... | |
You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | C | a4849505bca48b408a5e8fb5aebf5cb6 | 0e015114ea212b236e14d94886dbfc92 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"graphs"
] | 1530628500 | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | null | PASSED | 2,100 | standard input | 4 seconds | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | #include<stdio.h>
int n,d,k;
void cat(){
int i,j;
long long l,r;
if(n<=d){
printf("NO\n");
return;
}
r=1;
l=k;
for(i=1;i*2-1<=d;i++){
j=d-(i*2-1);
if(n-j-r<=l/k){
break;
}
j--;
if(j>=0&&n-j-r>l/k&&n-j<=r+l){
break;
}
r+=l;
l*=k-1;
}
if(i*2-1>d){
printf("NO\n");
return;
}
if(j>0&... | |
You are given three integers $$$n$$$, $$$d$$$ and $$$k$$$.Your task is to construct an undirected tree on $$$n$$$ vertices with diameter $$$d$$$ and degree of each vertex at most $$$k$$$, or say that it is impossible.An undirected tree is a connected undirected graph with $$$n - 1$$$ edges.Diameter of a tree is the max... | If there is no tree satisfying the conditions above, print only one word "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), and then print $$$n - 1$$$ lines describing edges of a tree satisfying the conditions above. Vertices of the tree must be numbered from $$$1$$$ to $$$n$$$. You can pr... | C | a4849505bca48b408a5e8fb5aebf5cb6 | 8a3475752407e14ea0eeb99dfd82e48e | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"constructive algorithms",
"graphs"
] | 1530628500 | ["6 3 3", "6 2 3", "10 4 3", "8 5 3"] | null | PASSED | 2,100 | standard input | 4 seconds | The first line of the input contains three integers $$$n$$$, $$$d$$$ and $$$k$$$ ($$$1 \le n, d, k \le 4 \cdot 10^5$$$). | ["YES\n3 1\n4 1\n1 2\n5 2\n2 6", "NO", "YES\n2 9\n2 10\n10 3\n3 1\n6 10\n8 2\n4 3\n5 6\n6 7", "YES\n2 5\n7 2\n3 7\n3 1\n1 6\n8 7\n4 3"] | #define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
#define Max(X,Y) ((X)>(Y) ? (X) : (Y))
#... | |
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1,βa2,β...,βan}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t... | Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation. | C | ed9375dfd4749173472c0c18814c2855 | 8bb635228822a38b9df51b35ae051812 | GNU C | standard output | 512 megabytes | train_002.jsonl | [
"data structures",
"brute force"
] | 1489590300 | ["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"] | NoteConsider the first sample.After the first Anton's operation the permutation will be {1,β2,β3,β5,β4}. There is only one inversion in it: (4,β5).After the second Anton's operation the permutation will be {1,β5,β3,β2,β4}. There are four inversions: (2,β3), (2,β4), (2,β5) and (3,β4).After the third Anton's operation th... | PASSED | 2,200 | standard input | 4 seconds | The first line of the input contains two integers n and q (1ββ€βnββ€β200β000,β1ββ€βqββ€β50β000)Β β the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1ββ€βli,βriββ€βn)Β β the indices of elements that Anton swaps during the i-th... | ["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"] | #include <math.h>
#include <stdio.h>
/* http://codeforces.com/contest/785/submission/25670789 (Dukkha) */
#define N 200000
int aa[N], bb[N];
int n, k;
int search(int i, int j, int a) {
int lower = i - 1, upper = j, mid;
while (upper - lower > 1) {
mid = (lower + upper) / 2;
if (bb[mid] <= a)
lower = mid;
... | |
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1,βa2,β...,βan}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t... | Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation. | C | ed9375dfd4749173472c0c18814c2855 | b7463902cbc53661bf03dcb2e5ba2dc5 | GNU C | standard output | 512 megabytes | train_002.jsonl | [
"data structures",
"brute force"
] | 1489590300 | ["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"] | NoteConsider the first sample.After the first Anton's operation the permutation will be {1,β2,β3,β5,β4}. There is only one inversion in it: (4,β5).After the second Anton's operation the permutation will be {1,β5,β3,β2,β4}. There are four inversions: (2,β3), (2,β4), (2,β5) and (3,β4).After the third Anton's operation th... | PASSED | 2,200 | standard input | 4 seconds | The first line of the input contains two integers n and q (1ββ€βnββ€β200β000,β1ββ€βqββ€β50β000)Β β the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1ββ€βli,βriββ€βn)Β β the indices of elements that Anton swaps during the i-th... | ["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"] | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
/* http://codeforces.com/contest/785/submission/25674261 (Dukkha) */
int **tt, *aa;
int n, k, m;
void alloc() {
int i;
aa = malloc(n * sizeof *aa);
tt = malloc(m * sizeof *tt);
for (i = 0; i < m; i++)
tt[i] = calloc(n, sizeof *tt[i]);
}
void update(int... | |
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1,βa2,β...,βan}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t... | Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation. | C | ed9375dfd4749173472c0c18814c2855 | 149bf669930805cd426bdde19f3b97c1 | GNU C | standard output | 512 megabytes | train_002.jsonl | [
"data structures",
"brute force"
] | 1489590300 | ["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"] | NoteConsider the first sample.After the first Anton's operation the permutation will be {1,β2,β3,β5,β4}. There is only one inversion in it: (4,β5).After the second Anton's operation the permutation will be {1,β5,β3,β2,β4}. There are four inversions: (2,β3), (2,β4), (2,β5) and (3,β4).After the third Anton's operation th... | PASSED | 2,200 | standard input | 4 seconds | The first line of the input contains two integers n and q (1ββ€βnββ€β200β000,β1ββ€βqββ€β50β000)Β β the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1ββ€βli,βriββ€βn)Β β the indices of elements that Anton swaps during the i-th... | ["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"] | #include <stdio.h>
#include <string.h>
#define N0 1877
typedef long long LL;
int n,m,q,a[200010],b[200010];
void update(int pos,int val);
int count(int pos);
int query(int pos,int val);
int main(void)
{
//freopen("permutation.in","r",stdin);
//freopen("permutation.out","w",stdout);
scanf("%d%d",&n,&q);
... | |
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1,βa2,β...,βan}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t... | Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation. | C | ed9375dfd4749173472c0c18814c2855 | 904cd96b2da2b2059e422a8674781274 | GNU C | standard output | 512 megabytes | train_002.jsonl | [
"data structures",
"brute force"
] | 1489590300 | ["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"] | NoteConsider the first sample.After the first Anton's operation the permutation will be {1,β2,β3,β5,β4}. There is only one inversion in it: (4,β5).After the second Anton's operation the permutation will be {1,β5,β3,β2,β4}. There are four inversions: (2,β3), (2,β4), (2,β5) and (3,β4).After the third Anton's operation th... | PASSED | 2,200 | standard input | 4 seconds | The first line of the input contains two integers n and q (1ββ€βnββ€β200β000,β1ββ€βqββ€β50β000)Β β the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1ββ€βli,βriββ€βn)Β β the indices of elements that Anton swaps during the i-th... | ["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"] | #include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#define LIM 2000
#define MAX 200010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
long long res = 0;
int n, m, d, q, lim, ar[MAX], lol[MAX], tmp[MAX], tree[(MAX / LIM) + 5][MAX];
void update(int ... | |
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1,βa2,β...,βan}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t... | Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation. | C | ed9375dfd4749173472c0c18814c2855 | f8e6a1c372f2f0af7bf0342dbc2c4729 | GNU C | standard output | 512 megabytes | train_002.jsonl | [
"data structures",
"brute force"
] | 1489590300 | ["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"] | NoteConsider the first sample.After the first Anton's operation the permutation will be {1,β2,β3,β5,β4}. There is only one inversion in it: (4,β5).After the second Anton's operation the permutation will be {1,β5,β3,β2,β4}. There are four inversions: (2,β3), (2,β4), (2,β5) and (3,β4).After the third Anton's operation th... | PASSED | 2,200 | standard input | 4 seconds | The first line of the input contains two integers n and q (1ββ€βnββ€β200β000,β1ββ€βqββ€β50β000)Β β the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1ββ€βli,βriββ€βn)Β β the indices of elements that Anton swaps during the i-th... | ["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"] | #include <stdio.h>
#define BLOCKSIZE 1000
#define BLOCK(x) ((x - 1) / BLOCKSIZE + 1)
#define INDEX(x) ((x - 1) % BLOCKSIZE + 1)
void Swap(int *a, int *b) {
int t;
t = *a;
*a = *b;
*b = t;
}
int n, bt[205][200005];
void BITModify(int blk, int idx, int det) {
for (; idx <= n; idx += idx & -idx) bt[blk][idx] += det... | |
Let's assume that we are given an nβΓβm table filled by integers. We'll mark a cell in the i-th row and j-th column as (i,βj). Thus, (1,β1) is the upper left cell of the table and (n,βm) is the lower right cell. We'll assume that a circle of radius r with the center in cell (i0,βj0) is a set of such cells (i,βj) that .... | Print two integers β the maximum sum of numbers in the cells that are located into two non-intersecting circles and the number of pairs of non-intersecting circles with the maximum sum. If there isn't a single pair of non-intersecting circles, print 0 0. | C | a1ef0079119e18de424a81b05b68bb4c | 5db39811146b1cc1edff653bb30c467c | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"data structures",
"implementation",
"brute force"
] | 1384156800 | ["2 2 0\n1 2\n2 4", "5 6 1\n4 2 1 3 2 6\n2 3 2 4 7 2\n5 2 2 1 1 3\n1 4 3 3 6 4\n5 1 4 2 3 2", "3 3 1\n1 2 3\n4 5 6\n7 8 9"] | null | PASSED | 2,500 | standard input | 4 seconds | The first line contains three integers n, m and r (2ββ€βn,βmββ€β500, rββ₯β0). Each of the following n lines contains m integers from 1 to 1000 each β the elements of the table. The rows of the table are listed from top to bottom at the elements in the rows are listed from left to right. It is guaranteed that there is at l... | ["6 2", "34 3", "0 0"] | #include <stdio.h>
#include <string.h>
#define MAXCIR 250033
#define MAXR 533
#define MAXC 533
typedef long long int llint;
llint num[MAXR][MAXC];
llint sum[MAXR][MAXC];
llint bound[MAXC];
llint map[MAXR][MAXC];
llint dp[MAXR][MAXC];
llint cc[MAXR][MAXC];
llint d[MAXR][2];
llint tot[MAXR][MAXC];
llint n,m,r;
llint ... | |
Let's assume that we are given an nβΓβm table filled by integers. We'll mark a cell in the i-th row and j-th column as (i,βj). Thus, (1,β1) is the upper left cell of the table and (n,βm) is the lower right cell. We'll assume that a circle of radius r with the center in cell (i0,βj0) is a set of such cells (i,βj) that .... | Print two integers β the maximum sum of numbers in the cells that are located into two non-intersecting circles and the number of pairs of non-intersecting circles with the maximum sum. If there isn't a single pair of non-intersecting circles, print 0 0. | C | a1ef0079119e18de424a81b05b68bb4c | 6a1daaffb2678dffcb4d5241375be413 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"data structures",
"implementation",
"brute force"
] | 1384156800 | ["2 2 0\n1 2\n2 4", "5 6 1\n4 2 1 3 2 6\n2 3 2 4 7 2\n5 2 2 1 1 3\n1 4 3 3 6 4\n5 1 4 2 3 2", "3 3 1\n1 2 3\n4 5 6\n7 8 9"] | null | PASSED | 2,500 | standard input | 4 seconds | The first line contains three integers n, m and r (2ββ€βn,βmββ€β500, rββ₯β0). Each of the following n lines contains m integers from 1 to 1000 each β the elements of the table. The rows of the table are listed from top to bottom at the elements in the rows are listed from left to right. It is guaranteed that there is at l... | ["6 2", "34 3", "0 0"] | #include <stdio.h>
#include <string.h>
#define MAXCIR 250033
#define MAXR 533
#define MAXC 533
typedef long long int imo;
imo num[MAXR][MAXC];
imo sum[MAXR][MAXC];
imo bound[MAXC];
imo map[MAXR][MAXC];
imo dp[MAXR][MAXC];
imo cc[MAXR][MAXC];
imo d[MAXR][2];
imo tot[MAXR][MAXC];
imo n,m,r;
imo can(imo dx,imo dy)
{
... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 7ba553b2c7a99b8d597c13d14fdd95c5 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int main()
{
int i,t;
int d,a,b,c,max;
scanf("%d",&t);
for(i=1;i<=t;i++){
scanf("%d %d %d",&a, &b, &c);
if (a>b && a>c){
max=a;
}
else if(b>a && b>c){
max=b;
}
else{
max=c;
}
d=max+1-a-b-c+... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | d5cb00bb911c753b02e0b26cbc74f5d9 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int main(){
int t=0;
long long int a,b,c,s,x,y,z;
scanf("%lld",&t);
while(t--){
scanf("%lld%lld%lld",&a,&b,&c);
s=a+b+c;
printf("%lld\n",s-2);
}
return 0;
}
| |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | cf05f369aff743a20f645a769119f220 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
main()
{
int t, max;
int a[3];
scanf("%d", &t);
while(t)
{
for(int i=0; i<3; i++)
scanf("%d", &a[i]);
max=a[0];
for(int i=1; i<3; i++)
{
if(max<a[i])
max = a[i];
}
pr... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 6aca36bab8691d3e80117b8f2d5ba8b6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
main()
{
long long t,a,b,c,d,i;
scanf("%lld",&t);
for(i=0;i<t;i++){
scanf("%lld %lld %lld",&a,&b,&c);
d=(a+b+c-1);
printf("%lld\n",d);
}
}
| |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 6ad31e87f7a4d8a8382ef26673719154 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | /*Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths a, b, and c.
Now he needs to find out some possible integer length d of the fourth straight fence segment so that he can build the fence using these fo... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | e0cbff24b9c3462fc132ed4d70bc5c8e | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
void solve() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if (a >= b && a >= c) printf("%d\n", a);
else if (b >= a && b >= c) printf("%d\n", b);
else printf("%d\n", c);
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
solve();
... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 66e7e987ec99d9dd2d205827c76f1594 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
main()
{
long long int t;
scanf("%I64d",&t);
while(t--)
{
long long int a,b,c;
scanf("%I64d%I64d%I64d",&a,&b,&c);
long long int sum=0;
sum=a+b+c-1;
printf("%I64d\n",sum);
}
}
| |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | fe59e75fc4655b91fb6d154598971fa1 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
#include<math.h>
int main(void)
{
int t;
scanf("%d",&t);
while(t--)
{
long long a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);
printf("%lld\n",(long long)sqrt(a*a+b*b+c*c));
// int ab=abs(a-b)+1;
// for(d=(a+b+c)/3;;d++)
// {
// if(d>abs(ab-c)&&d<abs(ab+c))
// {
// printf("%d\n",d);
// ... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | a55c98e77ce031929bc1dc44d1ca6158 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);
printf("%lld\n",(a+b+c-1));
}
return 0;
}
| |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | ebad55d4e43e0e3acf61b77ac23b780c | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
long long int a[t],b[t],c[t],r[t],d[t];
for(int i=1;i<=t;i++)
{
scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
r[i]=abs(a[i]-b[i]);
d[i]=c[i]+r[i];
printf("%lld\n",d[i]);
}
} | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 2b3a3eb20364eff103a5ca6922a36bb9 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
int x=(a>b)? a:b;
int y=(x>c)?x:c;
printf("%d\n",y+1);
}
return 0;
} | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 85949ed25b6680631886514defac52ce | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include <stdio.h>
int main() {
int a, b, c, max, t, i;
scanf("%d", &t);
for (i = 0; i < t; i++) {
scanf("%d%d%d", &a, &b, &c);
max = a - b - c;
if (b - a - c > max) max = b - a - c;
if (c - a - b > max) max = c - a - b;
if (max < 0) max = 0;
printf("%d\n", m... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | cd66091ece2ba1a48d3f0dde9b583eaa | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include <stdio.h>
int main()
{
long long int t,a,b,c,d,i,j,x,y;
scanf("%lld",&t);
while(t--)
{
scanf("%lld%lld%lld",&a,&b,&c);
x=a+b+c-2;
printf("%lld\n",x);
}
return 0;
}
| |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 1e6cbe77e3a646149caca61f921b5eb9 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
#include<math.h>
int main(){
int t,a,b,c,i=0,l,u;
scanf("%d",&t);
while(i<t)
{
scanf("%d%d%d",&a,&b,&c);
l=c-a-b;
u=a+b+c;
if(l<0){
l=l*(-1);
}
printf("%d\n",l+1);
i++;
}
return 0;
} | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | be0cf8593401be339c21d63519c743b9 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int max(int a, int b) { return a > b ? a : b; }
int main() {
int t;
scanf("%d", &t);
while (t-- > 0) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int ans = max(a, max(b, c));
printf("%d\n", ans+1);
}
return 0;
} | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 6c48bccb66b0822dc8011e5903eefa53 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int xxx(int a,int b,int c)
{
if(a>b)
{
if(a>c)
return a;
else
return c;
}
else
{
if(b>c)
return b;
else
return c;
}
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("%d\n",xxx(a,b,c));
}
return 0;
} | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 27c9ec0ca3969de6db3c61848e50fa92 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int main()
{
long long a,b,c,d,n;
scanf("%lld",&n);
for(int i=0;i<n;i++){
scanf("%lld %lld %lld",&a,&b,&c);
printf("%lld\n",a+b+c-1);
}
return 0;
}
| |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 22fe54fa8cd93daabc6a830b07dcceff | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | //bismillah
#include<stdio.h>
int main()
{
int tc;
scanf("%d",&tc);
while(tc--)
{
unsigned long long int a,b,c;
scanf("%llu %llu %llu",&a,&b,&c);
printf("%llu\n",a+b+c-1);
}
return 0;
}
| |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 08ce2227c1b069f3629063e6d2df99fd | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include <stdio.h>
int findMax(int x, int y, int z)
{
if(x >= y && x >= z)
return x;
else if(y >= x && y >= z)
return y;
else
return z;
}
int main()
{
long long int t, i, a, b, c, d_1, d_2, d_3, d_low, d_up, A[1000] = {0};
scanf("%lld", &t);
for(i = 0 ; i < t ; i++... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 88d266cde21a3a09c22246fb63907e22 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | // Nothing Special
#include <stdio.h>
#include <inttypes.h>
int main() {
#ifdef NothingSpecial
freopen("std.in", "r", stdin);
freopen("std.out", "w", stdout);
#endif
short int _;
for (scanf("%hd", &_); _; _--) {
int64_t a, b, c;
scanf("%" PRId64 "%" PRId64 "%" PRId64, &a, &b, &c);
printf("%" PRId64 "\n", a ... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 3b254c1d26e38b5059823fa4a160fb41 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
long long int a,b,c;
while(t--)
{
scanf("%lld %lld %lld",&a,&b,&c);
printf("%lld\n",a+b+c-1);
}
return 0;
} | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 14b251f7b033bb56ac5c81c2028094e3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
long long int max(long long int x, long long int y);
int main()
{
int t;
scanf("%d\n", &t);
while(t--)
{
long long int a,b,c, d, num;
scanf("%llu %llu %llu\n", &a, &b, &c);
num = a+b+c-1;
printf("%llu\n", num);
}
return 0;
}
long long int max... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 57b38eebc08c525ca33a5ef9e1fcb0ce | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
unsigned long long int max(unsigned long long int x,unsigned long long int y);
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
unsigned long long int a,b,c, d, num;
scanf("%llu %llu %llu", &a, &b, &c);
num = a+b+c-1;
printf("%llu\n", num);
}
... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 2982f91b067619650617dcae90e41787 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include <stdio.h>
int main() {
int t;
scanf("%d", &t);
while (t--) {
long long int a, b, c;
scanf("%lld %lld %lld", &a, &b, &c);
printf("%lld\n", a + b + c - 1);
}
} | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | f50c3513fa6652de4e2326530ba3a75c | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int main(){
int test,i,j,k;
scanf("%d",&test);
while(test--){
scanf("%d %d %d",&i,&j,&k);
unsigned long int sum=i+j+k;
printf("%u\n",sum-1);
}
} | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | b5efbf36c1dd2a5bc81887e7f372e3a6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
long long int a, b, c;
for (; t > 0; t--)
{
scanf("%lld %lld %lld", &a, &b, &c);
printf("%lld\n", a + b + c - 1);
}
return 0;
} | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | 089920bae89065de8e5fbd2a732937bb | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
#include<math.h>
long long int min(long long int a,long long int b)
{
if(a<=b)
return(a);
return(b);
}
long long int mod(int a)
{
if(a<0)
return(-a);
else
return(a);
}
int main()
{
int t;scanf("%d",&t);
while(t--)
{
long long int a,b,c;scanf(... | |
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build th... | For each test case print a single integer $$$d$$$Β β the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists. | C | 40d679f53417ba058144c745e7a2c76d | e3e5072e732a581795c52ac5ae04466b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"geometry",
"math"
] | 1601827500 | ["2\n1 2 3\n12 34 56"] | NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$. | PASSED | 800 | standard input | 1 second | The first line contains a single integer $$$t$$$Β β the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$Β β the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$). | ["4\n42"] | #include<stdio.h>
int max(int a ,int b)
{
return a>b?a:b;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b,c,p;
scanf("%d%d%d",&a,&b,&c);
p=max(a,max(b,c));
printf("%d\n",p);
}
}
| |
One day Masha came home and noticed n mice in the corridor of her flat. Of course, she shouted loudly, so scared mice started to run to the holes in the corridor.The corridor can be represeted as a numeric axis with n mice and m holes on it. ith mouse is at the coordinate xi, and jth hole β at coordinate pj. jth hole h... | Print one integer number β the minimum sum of distances. If there is no solution, print -1 instead. | C | d9adb80515689c6939f8e010005f7208 | f8f8ecc1df8612bd7e1eab6483007be2 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"dp",
"sortings",
"greedy",
"data structures"
] | 1492266900 | ["4 5\n6 2 8 9\n3 6\n2 1\n3 6\n4 7\n4 7", "7 2\n10 20 30 40 50 45 35\n-1000000000 10\n1000000000 1"] | null | PASSED | 2,600 | standard input | 1.5 seconds | The first line contains two integer numbers n, m (1ββ€βn,βmββ€β5000) β the number of mice and the number of holes, respectively. The second line contains n integers x1,βx2,β...,βxn (β-β109ββ€βxiββ€β109), where xi is the coordinate of ith mouse. Next m lines contain pairs of integer numbers pj,βcj (β-β109ββ€βpjββ€β109,β1ββ€βcj... | ["11", "7000000130"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 5000
#define M 5000
#define INF 0x3f3f3f3f3f3f3f3fLL
int compare(const void *a, const void *b) {
int ia = *(int *) a;
int ib = *(int *) b;
return ia - ib;
}
struct V {
int x, c;
} vv[M];
int compare_V(const void *a, const void *b) {
struct V... | |
It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..There is a glob pattern in the statements (a string consisting of lowercase English letters, characters "?" and "*"). It is known... | Print n lines: in the i-th of them print "YES" if the pattern matches the i-th query string, and "NO" otherwise. You can choose the case (lower or upper) for each letter arbitrary. | C | c6633581d7424d670eaa0f8a5c8cc366 | e50038d81fdd6a9e6ac2c8cf9383e602 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"strings"
] | 1500906900 | ["ab\na?a\n2\naaa\naab", "abc\na?a?a*\n4\nabacaba\nabaca\napapa\naaaaax"] | NoteIn the first example we can replace "?" with good letters "a" and "b", so we can see that the answer for the first query is "YES", and the answer for the second query is "NO", because we can't match the third letter.Explanation of the second example. The first query: "NO", because character "*" can be replaced wi... | PASSED | 1,600 | standard input | 2 seconds | The first line contains a string with length from 1 to 26 consisting of distinct lowercase English letters. These letters are good letters, all the others are bad. The second line contains the patternΒ β a string s of lowercase English letters, characters "?" and "*" (1ββ€β|s|ββ€β105). It is guaranteed that character "*" ... | ["YES\nNO", "NO\nYES\nNO\nYES"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
char good[27];
int goodi[27]={0},n,i,m,pos1,pos2,flag,sl,ql,ql2,j,star;
char s[100005],q[100005];
scanf("%s", good);
scanf("%s", s);
scanf("%d", &n);
m = strlen(good);
sl = strlen(s);
star=0;
for (i=0; i<sl; i++)
if (s... | |
It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..There is a glob pattern in the statements (a string consisting of lowercase English letters, characters "?" and "*"). It is known... | Print n lines: in the i-th of them print "YES" if the pattern matches the i-th query string, and "NO" otherwise. You can choose the case (lower or upper) for each letter arbitrary. | C | c6633581d7424d670eaa0f8a5c8cc366 | 98ef4bb8c34dfaf41faaa51a5681d676 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"strings"
] | 1500906900 | ["ab\na?a\n2\naaa\naab", "abc\na?a?a*\n4\nabacaba\nabaca\napapa\naaaaax"] | NoteIn the first example we can replace "?" with good letters "a" and "b", so we can see that the answer for the first query is "YES", and the answer for the second query is "NO", because we can't match the third letter.Explanation of the second example. The first query: "NO", because character "*" can be replaced wi... | PASSED | 1,600 | standard input | 2 seconds | The first line contains a string with length from 1 to 26 consisting of distinct lowercase English letters. These letters are good letters, all the others are bad. The second line contains the patternΒ β a string s of lowercase English letters, characters "?" and "*" (1ββ€β|s|ββ€β105). It is guaranteed that character "*" ... | ["YES\nNO", "NO\nYES\nNO\nYES"] | #include<stdio.h>
char GoodLetters[30], Pattern[1000000], Query[1000000];
int good(char a) {
int i;
for (i = 0; GoodLetters[i] != '\0'; i++) {
if (GoodLetters[i] == a)
return 1;
}
return 0;
}
int l(char *A) {
int i;
for (i = 0; A[i] != '\0'; i++)
;
return i;
}
int ch(char Q, char P) {
if (P == '?')
ret... | |
User ainta has a permutation p1,βp2,β...,βpn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1,βa2,β...,βan is prettier than permutation b1,βb2,β...,βbn, if and only if there exists an integer k (1ββ€βkββ€βn) where a1β=βb1,βa2β=βb2,β...,βakβ-β1β=βbkβ-β1 and akβ<βbk all h... | In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained. | C | a67ea891cd6084ceeaace8894cf18e60 | 17e619b9d6131c90b22070d414375690 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"graphs",
"math",
"dsu",
"sortings",
"dfs and similar"
] | 1419951600 | ["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"] | NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1,βp7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1,βp3),β(p4,βp5),β(p3,βp4). A permutation p is a sequence of integers p1,βp2,β...,βpn, consisting of n distinct positive integers, each of them does... | PASSED | 1,600 | standard input | 2 seconds | The first line contains an integer n (1ββ€βnββ€β300) β the size of the permutation p. The second line contains n space-separated integers p1,βp2,β...,βpn β the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co... | ["1 2 4 3 6 7 5", "1 2 3 4 5"] | #include<stdio.h>
int ara[300];
char mat[300][301];
int col[300];
int tempara[300];
int idxara[300];
int start;
int end;
void Quick_sort(int *ara,int ini_indx,int fin_indx)
{
if(ini_indx>fin_indx) return;
int l1=ini_indx-1,l,tmp;
for(l=ini_indx;l<fin_indx;l++)
{
if(ara[l]<ara[fin_indx]){
... | |
User ainta has a permutation p1,βp2,β...,βpn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1,βa2,β...,βan is prettier than permutation b1,βb2,β...,βbn, if and only if there exists an integer k (1ββ€βkββ€βn) where a1β=βb1,βa2β=βb2,β...,βakβ-β1β=βbkβ-β1 and akβ<βbk all h... | In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained. | C | a67ea891cd6084ceeaace8894cf18e60 | 582fb1f20efac44b57cf14cd0b607a97 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"graphs",
"math",
"dsu",
"sortings",
"dfs and similar"
] | 1419951600 | ["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"] | NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1,βp7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1,βp3),β(p4,βp5),β(p3,βp4). A permutation p is a sequence of integers p1,βp2,β...,βpn, consisting of n distinct positive integers, each of them does... | PASSED | 1,600 | standard input | 2 seconds | The first line contains an integer n (1ββ€βnββ€β300) β the size of the permutation p. The second line contains n space-separated integers p1,βp2,β...,βpn β the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co... | ["1 2 4 3 6 7 5", "1 2 3 4 5"] | #include<stdio.h>
#define SZ 302
char mat[SZ][SZ];
int a[SZ];
int vis[SZ];
int route[SZ],sz;
int n;
int fixed[SZ];
void dfs(int v,int dest)
{
vis[v]=1;
int i;
for(i=1;i<=n;i++)
{
if(mat[v][i]=='1' && !vis[i])
{
route[sz++]=i;
if(i==dest)
{ vis[i]=... | |
User ainta has a permutation p1,βp2,β...,βpn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1,βa2,β...,βan is prettier than permutation b1,βb2,β...,βbn, if and only if there exists an integer k (1ββ€βkββ€βn) where a1β=βb1,βa2β=βb2,β...,βakβ-β1β=βbkβ-β1 and akβ<βbk all h... | In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained. | C | a67ea891cd6084ceeaace8894cf18e60 | 260551192803f440b1486252dc89b495 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"greedy",
"graphs",
"math",
"dsu",
"sortings",
"dfs and similar"
] | 1419951600 | ["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"] | NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1,βp7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1,βp3),β(p4,βp5),β(p3,βp4). A permutation p is a sequence of integers p1,βp2,β...,βpn, consisting of n distinct positive integers, each of them does... | PASSED | 1,600 | standard input | 2 seconds | The first line contains an integer n (1ββ€βnββ€β300) β the size of the permutation p. The second line contains n space-separated integers p1,βp2,β...,βpn β the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co... | ["1 2 4 3 6 7 5", "1 2 3 4 5"] | #include<stdio.h>
#include<string.h>
int main(){
int n, a[307]={0};
char b[307][307]={0};
int i, j, k, h, temp, t, yes;
while( scanf("%d", &n) != EOF){
getchar();
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
for(i = 1; i <= n; i ++){
scanf("%d",&a[i]);
... | |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | a4c0cc07e591539070533a9282b6e52a | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | #include<stdio.h>
int main(){
int n,m;
scanf("%d",&n);
scanf("%d",&m);
int a[n],b[n],j,k;
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<n;i++){
scanf("%d",&b[i]);
}
int c[2*n];
c[0]=a[0];
c[2*n-1]=b[0];
j=1;
k=1;
while(j<(2*n-1)){
... | |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | 33a169f7086e56db438ded18e05ae9b4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | #include <stdio.h>
int main ()
{
int n, m, i;
double c = 1.0, x;
scanf ("%d%d", &n, &m);
for (i = 0; i < n * 2; i++)
{
scanf ("%lf", &x);
c *= 1 - 1 / x;
}
printf ("%.10lf", c > 0 ? m / c - m : -1);
return 0;
}
| |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | b718587a348c0170a29216ed53903242 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | #include <stdio.h>
#include <stdlib.h>
#define MAX 1000
void read(double *vec, int size) {
for (int i = 0; i < size; i++) {
scanf("%lf", vec + i);
}
}
double calculate(double correlation, double weight) {
if (correlation - 1.0 <= 0) return -1;
else return weight / (correlation - 1.0);
}
void doer(double *a, d... | |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | a981ce263bbde7082530252f06d633da | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | #include <stdio.h>
int main()
{
int n, m, i;
double c = 1.0, x;
scanf("%d%d", &n, &m);
for (i = 0; i < 2 * n; i++)
{
scanf("%lf", &x);
c = c * (1 - 1 / x);
}
float w = m / c - m;
if (c>0)
printf("%.10lf",w);
else
printf("-1");
} | |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | 8dafe771c551e02e5df8fe50cecc0fdc | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | #include<stdio.h>
main()
{
int n, mass; double ans;
scanf("%d %d",&n,&mass);
int i,a[n],b[n];
for(i=0;i<n;i++)scanf("%d",&a[i]);
for(i=0;i<n;i++)scanf("%d",&b[i]);
ans=a[0]-1;
for(i=1;i<n;i++)
{
ans=ans-(ans/b[i]);
ans=ans-(ans/a[i]);
}
ans=ans-(ans/b[0]);
if(... | |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | d535174854bb2c6578bd7cf2a33b1b2d | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | #include <stdio.h>
int main ()
{
int n, m, i;
double c = 1.0, x;
scanf ("%d%d", &n, &m);
for (i = 0; i < n * 2; i++)
{
scanf ("%lf", &x);
c *= 1 - 1 / x;
}
printf ("%.10f\n", c > 0 ? m / c - m : -1);
return 0;
}
| |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | 3c03de8e2e46c39d51e44a5e43c65dc4 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | #include <stdio.h>
int main ()
{
int n, m, i;
double c = 1.0, x;
scanf ("%d%d", &n, &m);
for (i = 0; i < n * 2; i++)
{
scanf ("%lf", &x);
c *= 1 - 1 / x;
}
printf ("%.10lf", c > 0 ? m / c - m : -1);
return 0;
}
| |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | b87060b15e52ed0291e2388ad99bddd3 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | #include <stdio.h>
int main ()
{
int n, m, i;
double c = 1.0, x;
scanf ("%d%d", &n, &m);
for (i = 0; i < n * 2; i++)
{
scanf ("%lf", &x);
c *= 1 - 1 / x;
}
printf ("%.10lf\n", c > 0 ? m / c - m : -1);
return 0;
}
| |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | 6046eb5449554a6868114016edc20d84 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | #include<stdio.h>
int main() {
int n,m,i;
double c=1.0,x;
scanf("%d%d",&n,&m);
for(i=0;i<2*n;i++){
scanf("%lf",&x);
c=c*(1-1/x);
}
float w=m/c-m;
c>0?printf("%.10lf",w):printf("-1");
}
| |
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $$$n - 2$$$ intermediate planets. Formally: we number all the planets from $$$1$$$ to $$$n$$$. $$$1$$$ is Earth, $$$n$$$ is Mars. Natasha will make exactly $$$n$$$ flights: $$$1 \to 2 \to \ldots n \to 1$$$.Flight... | If Natasha can fly to Mars through $$$(n - 2)$$$ planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number $$$-1$$$. It is guaranteed, that if Natasha can make a flight, then it takes no more than $$$10^9$$$ tons of fuel. The answer will be consider... | C | d9bd63e03bf51ed87ba73cd15e8ce58d | c4acce5cc11f0c693e90bd0a711af957 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"binary search",
"math"
] | 1532617500 | ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3"] | NoteLet's consider the first example.Initially, the mass of a rocket with fuel is $$$22$$$ tons. At take-off from Earth one ton of fuel can lift off $$$11$$$ tons of cargo, so to lift off $$$22$$$ tons you need to burn $$$2$$$ tons of fuel. Remaining weight of the rocket with fuel is $$$20$$$ tons. During landing on Ma... | PASSED | 1,500 | standard input | 1 second | The first line contains a single integer $$$n$$$ ($$$2 \le n \le 1000$$$)Β β number of planets. The second line contains the only integer $$$m$$$ ($$$1 \le m \le 1000$$$)Β β weight of the payload. The third line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 1000$$$), where $$$a_i$$$ is the numbe... | ["10.0000000000", "-1", "85.4800000000"] | //codechef tutorial multiplication
#include<stdio.h>
int main()
{
long long i,j,k,l,c,n,m,mul,sum;
double x,y,z,w;
scanf("%lld%lld",&n,&m);
int a[2][n];
c=0;
y=1;
for(i=0;i<2;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
if(a[i][j]==1)
c++;
}
}
if(c!=0)
printf("-1");
else
{
for... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | ab04ebd8f1081ba7882a23f67c82ac1b | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | #include<stdio.h>
#include<stdlib.h>
int cmpfunc (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
long long find(long long a[],long long n,long long x){
long long i;
for(i=0;i<n;i++)
{
if(a[i]==x)
return i+1;
}
}
long long check(long long b[],long long n,long long i){
long long ... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | 847d18274bc000cf8bb5da45fbc1910d | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | #include<stdio.h>
#define MAX 200000
int temp[MAX];
void mergesort(int a[],int indices[],int first,int last)
{
if(first==last) return;
int middle=(first+last)/2;
mergesort(a,indices,first,middle);
mergesort(a,indices,middle+1,last);
int i,j,k;
for(i=first,j=first,k=middle+1; i<=last; i++)
{
... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | 4739ebb2a693bb3d4cfebce43c22baa0 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | #include<stdio.h>
#include<stdlib.h>
int cmpfunc (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
long long find(long long a[],long long n,long long x){
long long i;
for(i=0;i<n;i++)
{
if(a[i]==x)
return i+1;
}
}
long long check(long long b[],long long n,long long i){
long... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | 0c46fd6613b76ff7330d9f40666207e6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | #include<stdio.h>
#include<string.h>
void merge(long long int a[],int p,int q,int r){
int i,j,k;
int n1=q-p+1;
int n2=r-q;
long long int L[n1];
long long int R[n2];
for(i=0;i<n1;i++)
L[i]=a[p+i];
for(j=0;j<n2;j++)
R[j]=a[q+j+1];
i=0;
j=0;
k=p;
while(i<n1 && j<... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | 4e35899f0e9a6f7563e0fc2838f8acd3 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | /* upsolve with Dukkha */
#include <stdio.h>
#include <stdlib.h>
#define N 200000
int aa[N], ii[N];
int compare(const void *a, const void *b) {
int i = *(int *) a;
int j = *(int *) b;
return aa[i] - aa[j];
}
int check(int a0, int a1, int l, int r) {
int c, a, i;
c = a1 - a0, a = a1;
for (i = l; i < r; i++)
... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | f390932e320342d889d49075d9e1fdd6 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | #include<stdio.h>
#include<stdlib.h>
typedef struct{
int num, pos;
} Num;
int comp(const void * a, const void * b){
return ((Num*)a)->num-((Num*)b)->num;
}
Num b[200000];
int main(){
int n, i, c, torf;
scanf("%d", &n);
if(n<4){
printf("1\n");
return 0;
}
for(i=0;i<n;++i){
scanf("%d", &b[i].num);
b[i]... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | f35f8af3b8f5494e9422934223985567 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | #include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
void msort_memcpy (uint8_t * restrict dst, uint8_t * restrict src, size_t size) {
while (size--) {
*dst++ = *src++;
}
}
void msort (void * const array, const size_t num, const size_t size, int (* const cmp) (const void *, const void *)) {
typedef struc... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | 0c6556442ea1c804a3c6b7c80768cc8a | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef struct
{
int number;
int value;
} element;
typedef const element * Element;
int compare(const void *p1, const void *p2)
{
if (((Element)p1)->value != ((Element)p2)->value)
return ((Element)p1)->value - ((Element)p2)->value;
retu... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | e245ab6dcaea4b8af54d7988c32e8a06 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | #include <stdio.h>
#include <stdlib.h>
int lcmp(const void* a, const void *b)
{
return *(int*)a - *(int*)b;
}
int k;
int *v, *ov;
int first(int skip) {
return skip==0?1:0;
}
int next(int i, int skip)
{
if (++i == skip) ++i;
return i;
}
int walk(int *skip) {
int c, n, d;
c = first(*skip);
d = v[next(... | |
A sequence $$$a_1, a_2, \dots, a_k$$$ is called an arithmetic progression if for each $$$i$$$ from $$$1$$$ to $$$k$$$ elements satisfy the condition $$$a_i = a_1 + c \cdot (i - 1)$$$ for some fixed $$$c$$$.For example, these five sequences are arithmetic progressions: $$$[5, 7, 9, 11]$$$, $$$[101]$$$, $$$[101, 100, 99]... | Print such index $$$j$$$ ($$$1 \le j \le n$$$), so that if you delete the $$$j$$$-th element from the sequence, you can reorder the remaining elements, so that you will get an arithmetic progression. If there are multiple solutions, you are allowed to print any of them. If there is no such index, print -1. | C | 6946f088e462d12da47419f492ad51ea | cad83c7e4c26ea6d67641ba50db3b5a8 | GNU C11 | standard output | 256 megabytes | train_002.jsonl | [
"implementation",
"math"
] | 1560955500 | ["5\n2 6 8 7 4", "8\n1 2 3 4 5 6 7 8", "4\n1 2 4 8"] | NoteNote to the first example. If you delete the $$$4$$$-th element, you can get the arithmetic progression $$$[2, 4, 6, 8]$$$.Note to the second example. The original sequence is already arithmetic progression, so you can delete $$$1$$$-st or last element and you will get an arithmetical progression again. | PASSED | 1,700 | standard input | 2 seconds | The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) β length of the sequence $$$b$$$. The second line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) β elements of the sequence $$$b$$$. | ["4", "1", "-1"] | #include<stdio.h>
#include<stdlib.h>
int cmpfunc (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
long long find(long long a[],long long n,long long x){
long long i;
for(i=0;i<n;i++)
{
if(a[i]==x)
return i+1;
}
}
long long check(long long b[],long long n,long long i){
long long ... | |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | 417ea6fff4fdbf7d70d5210e5e0d2e95 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | #include <stdio.h>
int main()
{
int n , m , a , b , p = 0 ;
scanf("%d %d",&n,&m) ;
int games[n] , bills[m] ;
for(a=0;a<n;a++) {
scanf("%d",&games[a]) ;
}
for(b=0;b<m;b++) {
scanf("%d",&bills[b]) ;
}
int... | |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | af16e9cbbca76fdf60607afe17918408 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | #include<stdio.h>
int main()
{
int n,m,a[1500],b[1500],i,j;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(j=0;j<m;j++)
scanf("%d",&b[j]);
j=0;
for(i=0;i<n;i++)
{
if(a[i]<=b[j])
{
j++;
if(j==m)break;
}
}
printf("%d",j);
return 0;
} | |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | cd21fc15e4910f6a53f210042a0626d1 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long
int main(void)
{
int game[1001],bil[1001],n,m,cn,i,j;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
scanf("%d",game+i);
... | |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | e758a8c4a5c98579ba4fda40da6033e9 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | #include<stdio.h>
int main()
{
int a[1010],c[1010],n,m,i,j,cnt=0,o,p;
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++)
scanf("%d",&c[i]);
for(j=1;j<=m;j++)
scanf("%d",&a[j]);
o=1;
p=1;
for( ;((o<=m)&&(p<=n)); )
{
if(a[o]>=c[p])
{
o++;... | |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | 316df4057db2ee61a20b44febbf04897 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i, x, y,c=0, no=0;
scanf("%d%d", &x, &y);
int a[x], b[y];
for(i=0;i<x;i++)
{
scanf("%d", &a[i]);
}
for(i=0;i<y;i++)
{
scanf("%d", &b[i]);
}
for(i=0;i<x;i++)
{
if(a[i]<=b[no])
{
no++;
}
if(no==y)
{
break;
}
}
printf("%d", no);
r... | |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | a10ac50c35e57228c6b523054ace7416 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | /******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
***********************************************... | |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | 5478ef2df88f0a6e76ef0ec540f2e3da | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | #include<stdio.h>
int main()
{
int i,j,k,l,n,m,t;
scanf("%d%d",&n,&m);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
int b[m];
for(t=0;t<m;t++)
scanf("%d",&b[t]);
l=0;
k=0;
j=0;
while(j<m&&k<n)
{
if(b[j]>=a[k])
{
j++;
k++;
l++;
}
else
k++;
}
printf("%d",l);
return 0;
}
| |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | 2c6568667f8bf6d4c692e701ce7ac4f6 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | #include<stdio.h>
#include<conio.h>
int main(){
int g,b;
scanf("%d",&g);
scanf("%d",&b);
int gl[g];
int bl[b];
int k;
for(k=0;k<g;k++){
scanf("%d",&gl[k]);
}
for(k=0;k<b;k++){
scanf("%d",&bl[k]);
}
int i=0,j=0,counter = 0;
while(i < g & j < b){
if(bl[j] >= gl[i]){
... | |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | f731e576db664109e118e5aa984c9c93 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | #include <stdio.h>
int main()
{
int n,m,i,j=0,T=0;
scanf("%d%d",&n,&m);
int c[n],a[m];
for (i=0; i<n; i++)
scanf("%d",&c[i]);
for (i=0; i<m; i++)
scanf("%d",&a[i]);
for (i=0; i<n; i++)
{
if(a[j]>=c[i])
{
T++;
j++;
if(j>=m)
... | |
Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right,... | Print a single integer β the number of games Maxim will buy. | C | c3f080681e3da5e1290ef935ff91f364 | 8711fb2055461385db54ef76c059bc86 | GNU C | standard output | 256 megabytes | train_002.jsonl | [
"implementation"
] | 1531578900 | ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000"] | NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter unti... | PASSED | 800 | standard input | 1 second | The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) β the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th g... | ["3", "0", "4"] | #include<stdio.h>
int main(){
int n, m, i, k, cont;
scanf("%d%d", &n, &m);
int v[n], x[m];
for(i = 0; i < n; i++)
scanf("%d", &v[i]);
for(i = 0; i < m; i++)
scanf("%d", &x[i]);
i = k = cont = 0;
while(k < m && i < n){
if(v[i] <= x[k]){
cont++;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.