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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | c0a6e19401d4b00ccb42ddecfa48308c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
#include<stdlib.h>
typedef long long int lli;
int cmpfunc(const void *a, const void *b){
return(*(int*)a - *(int*)b);
}
int main() {
int m,n;
scanf("%d %d", &m, &n);
int ans=0;
int arr[m];
for(int i=0;i<m;i++){
scanf("%d", &arr[i]);
}
qsort(arr,m,sizeof(int), cmpfunc);
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 8ee511f941b8eae5d5d54df4b638a5bd | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
int main()
{
int n,m,temp,sum=0;
scanf("%d%d",&n,&m);
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | bb41e069f707489e1072bf9ae791853f | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#define MOD 1000000007
#define MAX(a, b) (a>b?a:b)
#define MIN(a, b) (a<b?a:b)
int compare(const void* a, const void* b) {
return *(int*)a-*(int*)b;
}
int abs(int n) {
if(n < 0)
return n*(-1);
return n;
}
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | be579bbaab3ec03e9919d78fd9dde706 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
#include<string.h>
int main()
{
int i,j, n, m, swapped, sum=0;
int a[101], b[101], temp;
scanf("%d %d", &n, &m);
for(i=0; i<n; i++)
scanf("%d", &b[i]);
for(i=0; i<n-1; i++)
{
for(j=0; j<n-1-i; j++)
{
if(b[j]>b[j+1])
{
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 285154983afa3b726b12eda735634af0 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
int main (){
int n,m,total = 0;
scanf ("%d %d",&n,&m);
int price[n];
for (int i = 0;i<n;i++){
scanf ("%d",&price[i]);
}
for (int i = 0;i<n;i++){
for (int j = 0;j<n-1;j++){
if (price[j] > price[j+1]){
int temp = price[j];
price[j] = price[j+1];
price[j+1] = temp;
}
}
}
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 5da3cbdbc4bca583b239624d43359cb1 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main(){
int n,m,a[1004],ne[123],k=0,s=0,t;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<n;i++){
if(a[i]<0){
ne[k]=a[i];
k++;
}
}
for(int i=0;i<k;i++){
for(int j=0;j<k-i;j++){
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | ef6b17c028e0e9d58559ae8cc369f933 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int n, m, i, j, k, sum = 0, temp;
scanf("%d%d",&n,&m);
int a[n+1], b[m+1];
for(i = 1, j = 1; i <= n; i++){
scanf("%d",&a[i]);
if(a[i] < 0){
b[j] = a[i];
j++;
}
}
for(i = 1; i < j; i++){
for(k = 1; k < j - i; ... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 6f7ee430f37337d05ed313264f96b50a | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
#include <stdlib.h>
int ordena( const void *x, const void *y){
int a = *((int *) x);
int b = *((int *) y);
if(a < b)
return -1;
if(a > b)
return 1;
return 0;
}
int main(){
int n, x;
int total = 0;
scanf("%d %d", &n, &x);
int v[n];
for(int ... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 6bcb33893f324d6ff9d723ca6c682201 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | //Bismillahir Rahmanir Rahim
#include<stdio.h>
int main()
{
int x,y,i,s[100],j,temp,sum=0;
scanf("%d%d",&x,&y);
for(i=1; i<=x; i++)
{
scanf("%d",&s[i]);
}
for(i=1; i<=x; i++)
{
for(j=1; j<=x; j++)
{
if(s[i]<=s[j])
{
temp=s[i];
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | ce473c20a0e5dc2a811b8a44586c2708 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
#include<stdlib.h>
int main()
{
int n,m,i,a[10000],sum=0,temp,j;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 48e86c886a8a0dd35159c0e6178af75a | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
#include<string.h>
int main()
{
int arr[105],n,m,i,j,temp,sum=0,number;
scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(arr[i]>=arr[j])
{
temp=arr... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 46761498d8b108f08a31449b467fe8a6 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int sort(int arr[],int n)
{
int i,j,a;
for (i = 0; i < n; ++i)
{
for (j = i + 1; j < n; ++j)
{
if (arr[i] > arr[j])
{
a = arr[i];
arr[i] = arr[j];
arr[j] = a;
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 5826f5bb83bbd27d96acc2d6cf884e64 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
#include<stdlib.h>
int cmp(const void *,const void *);
int fun(int [],int ,int );
int cmp(const void *a,const void *b)
{
return *(int *)b-*(int *)a;
}
int fun(int a[],int n,int m)
{
int i,ans=0;
for(i=0;i<n;i++)
{
a[i]=-a[i];
}
qsort(a,n,sizeof(a[i]),cmp);
for(i=0;i... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 398e2511fa4adda59990875d68ce8a4f | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
int main()
{
int n,m;
scanf("%d %d",&n,&m);
int a[n],i,j,k,l;
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
if(a[i]>a[j])
{
k=a[j];
a[j]=a[i];
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | d18c32b30added98bb5e4fde1ad9a29c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
void swap(int arr[], int a, int b);
void sort(int arr[], int len);
int main(void) {
int n, m;
scanf("%d %d", &n, &m);
int a[100] = {0};
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
}
sort(a, n);
int c = 0;
for (int i = 0; i < m && a[i] < 0; ++i) {
if (a[i] < 0)
c... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 9179266ff9650c412515e239eb951b8b | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #pragma warning(disable:4996)
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define forn(i,n) for (i = 0; i<n; i++)
int lol(const void *x1, const void *x2)
{
return *(int*)x1 - *(int*)x2;
}
int gcd(int a, int b)
{
int c;
while (b)
{
c = a % b;
a = b;
b = c... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | ce470c7bffb5c30dd3aa9da4da16c575 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int n,m,i,j,k,s=0,t;
scanf("%d%d",&n,&m);
int arr[n],arr1[n];
for(i=0; i<n; i++)
scanf("%d",&arr[i]);
for(i=0,j=0; i<n; i++)
{
if(arr[i]< 0)
{
arr1[j]= -arr[i];
j++;
}
}
if(j<= m)
{
for(i... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | f7a572ad01c279fa7e1ee84f9773db9b | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
#include <stdlib.h>
int cm(const void* a, const void* b){return *(int *)a-*(int *)b;}
const int M = 102;
int main(){
int n,m,i,a[M],s=0;
scanf("%i%i",&n,&m);
for(i=0;i<n;i++) scanf("%i",a+i);
qsort(a,n,sizeof a[0],cm);
for(i=0;i<m;i++)
if(a[i]<0)
s+=a[i];
p... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 9ceb3326833364448a033cf2e258ec4c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
#include <stdlib.h>
int cmp (const void * a, const void * b) {
if(*(int*)a > *(int*)b) {
return 1;
}
if(*(int*)a < *(int*)b) {
return -1;
}
else {
return 0;
}
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
int tv[n];
for(int i=0; i<... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | bb57de764bff85b1cf07e07cbd4b8d2d | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int n,m;
scanf("%d %d\n",&n,&m);
int a[n],i;
for(i=0;i<n;i++)
scanf("%d ",&a[i]);
int min,pos;
for(i=0;i<n;i++)
{
min=a[i];
pos=i;
for(int j=i;j<n;j++)
{
if(min>a[j])
{
min=a[j];
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 569810fbcad2d273718b8c4c8a28c309 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int cmp(const void *a,const void *b){
int *a1=(int *)a,*b1=(int *)b;
return *a1-*b1;
}
int sets[1005],sum=0;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)scanf("%d",&sets[i]);
qsort(sets,n,sizeof(int),cmp);
for(int i=... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | b928a5aefcef367a5a3039a5e0df7e99 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
int main (){
int n,m,t = 0,i,j;
scanf ("%d %d",&n,&m);
int price[n];
for ( i = 0;i<n;i++){
scanf ("%d",&price[i]);
}
for ( i = 0;i<n;i++){
for ( j = 0;j<n-1-i;j++){
if (price[j] > price[j+1]){
int temp = price[j];
price[j] = price[j+1];
price[j+1] = temp;
}
}
}
for (i... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 463e61e2bbd38b8bd1a19253e7127dc2 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
int main (){
int n,m,t = 0,i,j;
scanf ("%d %d",&n,&m);
int price[n];
for ( i = 0;i<n;i++){
scanf ("%d",&price[i]);
}
for ( i = 0;i<n;i++){
for ( j = 0;j<n;j++){
if (price[j] > price[j+1]){
int temp = price[j];
price[j] = price[j+1];
price[j+1] = temp;
}
}
}
for (i = 0... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | c17f824106615408d95cae21f93eb7a5 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int ara[110];
int n,m;
while(2==scanf("%d%d",&n,&m))
{
int sum = 0,l=0,temp;
for(int i =0; i<n; i++)
{
scanf("%d",&temp);
if(temp <0)
{
ara[l++]=(-1*temp);
}
}
//print... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 33aa6e915c6799b932280600b55026fd | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int m,n,i,t,s=0;
scanf("%d%d",&n,&m);
int a[n];
for(i=0;i<n;++i)
scanf("%d",&a[i]);
for(int j=0;j<n;++j)
{
for(int k=0;k<n-j-1;++k)
{
if(a[k]>=a[k+1])
{
t=a[k];
a[k]=a[k+1];
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | edfc88fb71436cc191bd3cec76f389a2 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
int main(void) {
int n, m;
scanf("%d%d", &n, &m);
int arr[n];
for(int i = 0; i < n; i++) scanf("%d", arr+i);
int tot = 0;
for(int i = 0; i < m; i++){
int min = 1000, index = i;
for(int j = 0; j < n; j++){
if(arr[j]<min){
min = arr[j];
index = j;
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | b79180119cd76c21c076a074c9c95d1f | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<string.h>
#include<stdlib.h>
int main()
{
int i,n,a[1000],m,j,min,ans=0,minindex;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<m;i++)
{
min=1001;
for(j=0;j<n;j++)
{
if(a[j]<min)
{ min=a[j];
mininde... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 4214c943c5203e62f578e5a461cff0a8 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
#include<stdlib.h>
int sort(const void*x,const void*y)
{
return ( *(int*)x - *(int*)y );
}
int main()
{
int n,m,a[200],i,j,total=0;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
qsort(a,n,sizeof(int),sort);
for(j=0;j<m;j++)
{
if(a[j]<=... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 1fce72acc6dbaf3961d10aa782bde6a0 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
int c=*(int*)a-*(int*)b;
return c;
}
main()
{
int n,m;
scanf("%d %d",&n,&m);
int a[n],i;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
qsort(a,n,sizeof(int),cmp);
int s=0;
for(i=0;i<=m-1;i++)
{
if(a[i]<=0)
s+=a[i];
}
printf("%d",-1*... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | b69cd852bdbfa346afa4bdd50bc0c7ed | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int m,n,i,j,k,a[101],temp=0,s=0;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(k=0;k<m;k++)
{
if(a[k]<0)s=s+abs(a[k]);
}
printf("%d",s);
} | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 89a5acb567646816824e112309949e63 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int n, m;
scanf("%d%d", &n, &m);
int tv[n], i, j, a[1000], f = 0;
for(i=0; i<n; i++)
{
scanf("%d", &tv[i]);
if(tv[i]<0)
{
a[f] = tv[i];
f++;
}
}
for(i=0; i<f; i++)
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 37e6fef0f940f8f55f182c3d8f1ace67 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int n,m,i,x,a[1000],temp,j,max,sum=0;
scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
x=n;
for(i=0; i<x; i++)
{
max=a[0];
for(j=1; j<x; j++)
{
if(a[j]>max)
{
max=a[j];
}
else
{... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | c12e2aeac7265545541d344d550a8e46 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int m,n;
scanf("%d %d",&n,&m);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<n;i++){
for(int j=0;j<n-i-1;j++){
if(a[j]>a[j+1]){
int t=a[j];
a[j]=a[j+1];
a[j+1]=t;
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | a4f480fcded9394cb7f3471a3b93c410 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include<stdio.h>
int main()
{
int n,m,temp,ans=0;
scanf("%d%d",&n,&m);
int a[n+1],i,j;
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
for(i=1;i<=n;i++)
{
for(j=i;j<=n;j++)
{
if(a[j]<a[i])
{
temp=a[i];
a[i]=a[j];
... | |
Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price β their owners are ready to pay Bob if he buys their useless apparatus. Bob can Β«buyΒ» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | Output the only number β the maximum sum of money that Bob can earn, given that he can carry at most m TV sets. | C | 9a56288d8bd4e4e7ef3329e102f745a5 | 4cfc8ebcd092b4c6f962c173e21c5a26 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"sortings",
"greedy"
] | 1286802000 | ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7"] | null | PASSED | 900 | standard input | 2 seconds | The first line contains two space-separated integers n and m (1ββ€βmββ€βnββ€β100) β amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai (β-β1000ββ€βaiββ€β1000) β prices of the TV sets. | ["8", "7"] | #include <stdio.h>
#include <stdlib.h>
#include<math.h>
int cmpfunc(const void*a,const void*b){
return *(int *)a-*(int *)b;
}
int main() {
int n,m;
scanf("%d %d",&n,&m);
int arr[n];
for(int i=0;i<n;i++){
scanf("%d",&arr[i]);
}
qsort(arr,n,sizeof(int),cmpfunc);
int neg=0;
for(... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number β the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 6d452823b090177c520ddff0160c7fc4 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1ββ€βn,βmββ€β100) β the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include <stdio.h>
#include <stdlib.h>
int main()
{
int n,m,ans=0;
scanf("%d %d",&n,&m);
char data[n][m];
int i=0;
while(i<n*m) {
int a,b;
a = i / m;
b = i % m;
if (b==0) {
scanf("\n%c",&data[a][b]);
} else {
scanf("%c",&data[a][b]);
}
i++;
}
int j=0;
while(j<n) {
int k=0;
int br1 = 0;
while(k<m) {
int co... | |
Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.Let's consider a student the best at some sub... | Print the single number β the number of successful students in the given group. | C | 41bdb08253cf5706573f5d469ab0a7b3 | 87d457c2c0726d91bd0685d6b4d80326 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation"
] | 1329750000 | ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111"] | NoteIn the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.In the second sample test each student is the best at at least one subject. | PASSED | 900 | standard input | 1 second | The first input line contains two integers n and m (1ββ€βn,βmββ€β100) β the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces. | ["2", "3"] | #include<stdio.h>
char str[200][200];
char ara[200];
int main()
{
int n,m,i,j,k,max,count=0;
scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
{
scanf("%s",str[i]);
}
for(i=0;i<m;i++)
{
max=0;
for(j=0;j<n;j++)
{
if(str[j][i]>max)
max=str[j][i... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 3ad9e510a106563e7fcb1e62c224ca31 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] |
/*
_____________________________________________
PURPOSE :
created by -ABHINAV AGGARWAL
_____________________________________________
*/
#include <stdio.h>
int cmp(const void *a,const void *b)
{
double diff;
diff=*(double *)a-*(double *)b;
if (diff>0)
return 1;
else if (diff<0)
... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 82220025f58dee1be0594599ccc16f9c | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include <stdio.h>
int main()
{
int n,x0,y0,x,y,vert,ind,i,count;
count=ind=vert=0;
scanf("%d %d %d",&n,&x0,&y0);
double slop[n],swap;
for(i=0;i<n;i++)
{
scanf("%d %d",&x,&y);
if(x==x0)
{
vert++;
slop[i]=0;
}
if(x!=x0) {slop[i]=(y0-... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 8244fe3040f24ad10465f6b3b80985b8 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include<stdio.h>
#include<limits.h>
int main()
{
int n,i,j,t,k,l,s=0,mx,my;
int a,b,x,y;
float m;
scanf("%d",&n);
int X[n],Y[n],vis[n];
scanf("%d",&x);
scanf("%d",&y);
for(i=0;i<n;i++)
{
scanf("%d",&X[i]);
scanf("%d",&Y[i]);
vis[i]=0;
}
int num=n;
... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 8b3f663b266dc26d6410e50619a1688a | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_TROOPS 1000
#define EPS 1e-9
int lfeq(long double x, long double y)
{
return (fabsl(x - y) <= EPS);
}
int cmp(const void *x, const void *y)
{
const long double *dx;
const long double *dy;
dx = x;
dy = y;
if(*dx < *dy)
return -1;
else if... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 8393b1ab277a7aed434242b14e0b5d97 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
typedef long int ll;
typedef struct
{
ll y,x;
ll n,d;
}L;
L p[1005],q;
ll gcd(ll a,ll b)
{
ll t,retval;
while(a%b!=0)
{
t=b;
b=a%b;
a=t;
}
retval=b;
return retval;
}
ll mi(ll a,ll b)
{
... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | b90b7fc87073f56a9058c6a7dacc081d | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include <stdio.h>
int main()
{
int i,j,n,count=0;
double x0,y0,x,y;
scanf("%d %lf %lf",&n,&x0,&y0);
double slope[n];
for(i=0;i<n;i++){
scanf("%lf %lf",&x,&y);
if(x!=x0){
if(y0==y) slope[i]=0;
else{
slope[i]=(y0-y)/(x0-x);
}
... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 329dbbfbadcbeb522326b4d14dbb32b6 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include <stdio.h>
int main()
{
int n, i, j, x[1001], y[1002], fin[1001]={0}, count=0;
scanf("%d", &n);
for(i=0; i<n+1; i++)
scanf("%d %d", &x[i], &y[i]);
for(i=1; i<=n; i++)
{
if(!fin[i])
{
count++;
fin[i]=count;
if(x[i]!=x... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 4611ec4464d153ee37ac8d54c77c2307 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include<stdio.h>
int main()
{
int x,y;
int a[1000][2];
int n;
int i,j;
int c=0;
int k[1000];
scanf("%d %d %d",&n,&x,&y);
for(i=0; i<n; i++,c++)
{
scanf("%d %d",&a[i][0],&a[i][1]);
for(j=0; j<i; j++)
{
if((a[i][0]-x)*(a[j][1]... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 94cbdb7340d0dcb3e59c01d2233594da | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include<stdio.h>
int main()
{
int i,j,k,n,m,x0,y0,t,x[1010],y[1010],count,count1,shot;
scanf("%d%d%d",&n,&x0,&y0);
for(i=0;i<n;i++)
scanf("%d%d",&x[i],&y[i]);
shot=n;
count1=0;
for(i=0;i<n;i++)
{
count=0;
if(x[i]!=-100000&&y[i]!=-100000)
{
for(j=i+1;j<n;j... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 45ca1388ffb57a687a52c6b4772b53b5 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include<stdio.h>
void quicksort(double x2[],double first,double last);
int main()
{
long int n,i,j;
double x0,y0,count=1;
scanf("%ld%lf%lf",&n,&x0,&y0);
double a[n];
for(i=0;i<n;i++)
{
double x,y;
double m=0;
scanf("%lf%lf",&x,&y);
if(x0-x!=0)
{
... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | b2b33ac2959f0db9fc3f836b64284dd8 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include <stdio.h>
#include <math.h>
#include <string.h>
int main(void)
{
int n, x0, y0;
scanf("%d %d %d", &n, &x0, &y0);
int coordinate[n][2];//0 is x and 1 is y
int flag[n];
int i, j;
for (i = 0; i < n; ++i) {
scanf("%d %d", &coordinate[i][0], &coordinate[i][1]);
flag[i] = 1;
... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | 621c3f27ef06bede74e91208c5d4d883 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include<stdio.h>
int arr[2000][3];
int equation(int x1, int y1, int x2, int y2, int x3, int y3) {
return (y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2);
}
int main(){
int a,b,c,d;
int x,y;
scanf("%d%d%d",&a,&x,&y);
int i;
for(i=0;i<a;i++){
scanf("%d%d",&arr[i][0],&arr[i][1]);
}
... | |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x,βy) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0,βy0). In one shot it can can de... | Print a single integer β the minimum number of shots Han Solo needs to destroy all the stormtroopers. | C | 8d2845c33645ac45d4d37f9493b0c380 | bf55b036ca93b34dffdd496b296e9611 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"geometry",
"math",
"implementation",
"data structures",
"brute force"
] | 1423931400 | ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0"] | NoteExplanation to the first and second samples from the statement, respectively: | PASSED | 1,400 | standard input | 1 second | The first line contains three integers n, x0 ΠΈ y0 (1ββ€βnββ€β1000, β-β104ββ€βx0,βy0ββ€β104) β the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each xi, yi (β-β104ββ€βxi,βyiββ€β104) β the coordinates of the stormtroopers on the battlefield. It is guaranteed tha... | ["2", "1"] | #include<stdio.h>
int arr[2000][3];
int equation(int x1,int y1,int x2,int y2,int x3,int y3){
return (y1-y2)*(x1-x3)==(y1-y3)*(x1-x2);
}
int main(){
int a,b,c,d;
int x,y;
scanf("%d%d%d",&a,&x,&y);
int i;
for(i=0;i<a;i++){
scanf("%d%d",&arr[i][0],&arr[i][1]);
}
int cnt=0;
int... | |
You are given an array $$$a$$$ consisting of $$$n$$$ elements. You may apply several operations (possibly zero) to it.During each operation, you choose two indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$; $$$i \ne j$$$), increase $$$a_j$$$ by $$$a_i$$$, and remove the $$$i$$$-th element from the array (so the indic... | For each test case, print the answer as follows: In the first line, print $$$k$$$ β the minimum number of operations you have to perform. Then print $$$k$$$ lines, each containing two indices $$$i$$$ and $$$j$$$ for the corresponding operation. Note that the numeration of elements in the array changes after removing el... | C | 2ff113d7c71c6e91c8254cbdaf27e9ae | 250392e34600f524d86d7cae696b6ed8 | GNU C11 | standard output | 512 megabytes | train_001.jsonl | [
"dp",
"bitmasks",
"brute force"
] | 1587911700 | ["4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14"] | NoteIn the first test case, the sequence of operations changes $$$a$$$ as follows:$$$[2, 1, 3, 5, 1, 2, 4, 5] \rightarrow [2, 1, 3, 5, 1, 4, 7] \rightarrow [1, 3, 5, 1, 6, 7] \rightarrow [2, 3, 5, 6, 7]$$$. | PASSED | 3,000 | standard input | 7 seconds | The first line contains one integer $$$T$$$ ($$$1 \le T \le 10000$$$) β the number of test cases. Each test case consists of two lines. The first line contains one integer $$$n$$$ ($$$1 \le n \le 15$$$) β the number of elements in the initial array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$... | ["3\n6 8\n1 6\n4 1\n7\n1 15\n1 13\n1 11\n1 9\n1 7\n1 5\n1 3\n1\n2 1\n0"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#define N 15
#define B (1 << N)
#define C 14348907 /* C = 3^N */
#define INF 0x3f3f3f3f
int max(int a, int b) { return a > b ? a : b; }
int p3[N + 1];
void init() {
struct timeval tv;
int i;
gettimeofday(&tv, NULL);
srand(tv.tv_se... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | bb6ec994caebb050dc55f6d715fe0b43 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include <stdio.h>
#include <stdlib.h>
int seats[4][11];
int main()
{
int n = 0, k = 0, i = 0, j = 0, hold = 0, pos = 0;
scanf("%d", &n);
int nums[n], ans[n*n][2];
for(i = 0; i < n; i++)
scanf("%d", &nums[i]);
for(i = 0; i < n-1; i++)
{
hold = nums[i];
for(j = i+1; j < n... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | 901b80653821245f21cc57b24ae22f88 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
int main()
{
int n,c=0,d;
scanf("%d",&n);
long long a[n],m[n],r[n-1],s[n];
int p[n];
for(int i=0;i<n;i++)
{
scanf("%lld",&a[i]);
}
for(int i=0;i<n;i++)
{
m[i]=a[i];
d=i;
for(int j=i+1;j<=n-1;j++)
{
r[j-1]=m[i];
... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | f73048465f9a331c776f8d99f4f88172 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
#define int long long int
int arr[3100];
int store1[3100];
int store2[3100];
int main(void)
{
int n;
scanf("%lld",&n);
for(int q=0;q<n;q++)
scanf("%lld",&arr[q]);
int temp=0;int ind=0;int ctr1=0;
int ctr=0;int temp2=0;int tempo=0;
int swap=0;
int flag=0;
for(int w=0;w<n;w++)
{
t... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | f658e5dcfc8301d2815a9df6801fc6b6 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
/*void swap(int a,int b)
{
a=a+b;
b=a-b;
a=a-b;
}*/
int main()
{
int n,idx,temp,k=0;
scanf("%d",&n);
int ar[n],a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&ar[i]);
}
for(int j=0;j<n;j++)
{
int min_length=1000000001;
for(int i=j;i<n;i++)
... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | d0a550abe81badd3ac6340e0ed217e1d | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | /* https://codeforces.com/contest/489/submission/19697507 (rainboy) */
#include <stdio.h>
#define N 3000
#define INF 1000000001
int main() {
static int aa[N];
int n, i;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
printf("%d\n", n);
for (i = 0; i < n; i++) {
int j, j_, min, tmp;
min = I... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | c53cab4458737162373ae80515900ffc | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include <stdio.h>
#include <stdlib.h>
#define N 3000
int compare(const void *a, const void *b) {
int ia = *(int *) a;
int ib = *(int *) b;
return ia - ib;
}
int main() {
static int aa[N], bb[N], swaps[N][2];
int n, i, j, tmp, k;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &aa[i]);
bb[i] = aa... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | 1e103e35ae7894d5456764a69875c566 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
int main()
{
int n, a[3010],i,j,m,temp;
scanf("%d", &n);
for (i = 0; i < n; ++i)
scanf("%d", &a[i]);
printf("%d\n", n);
for (i = 0; i < n; ++i)
{
m = i;
temp = a[i];
for (j = i + 1; j < n; ++j)
{
if (a[j] < temp)
{
temp = a[j];
m = j;
}
}
a[m] = a[i];
a[i] = temp... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | ad319149fd99053e01111ab7a0a3061f | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
int main()
{
int n,i,j,k,min,a=0;
scanf("%d",&n);
int x[n];
int y[n][2];
for(i=0;i<n;i++)
scanf("%d",&x[i]);
for(j=0;j<n;j++)
{
min=j;
for(i=j+1;i<n;i++)
{
if(x[i]<x[min])
{
min=i;
}
... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | 5dedf0f71e76c925bc0c7e0b2f7157ad | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
int i,j,temp,swapi[3002],swapj[3002],cnt,min;
int main()
{
int n,min_index,j;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++)
{
min_index=i;
for(j=i+1;j<n;j++)
{if(a[j]<a[min_index])
... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | a74c738e45b3fb041d57febe45291d7f | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
int main()
{
int n,x=0,idx;
scanf("%d",&n);
int in[n],ou[n];
long long ara[n];
long long min;
for(int i=0;i<n;i++)
{
scanf("%I64d",&ara[i]);
in[i]=-1;
ou[i]=-1;
}
for(int i=0;i<n;i++)
{
min=ara[i];
idx=i;
for(int j... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | 1604299f45c13aaab53348973e0dbaae | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include <stdio.h>
int min(int* a,int i,int n)
{
int j=0,mini=i;
for(j=i;j<n;j++)
{
if(a[mini]>a[j])
mini=j;
}
return mini;
}
int main()
{
int n,i;
scanf("%d",&n);
int a[n];
int b[2*n];
int k,count=0,p=0,j;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | fcf4516bcc7151bcbea7b4b940b9e75b | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
int n,i,j,sel;
scanf("%d",&n);
int *arr=malloc(sizeof(int)*n);
for (i=0;i<n;i++)
scanf("%d",&arr[i]);
printf("%d\n",n);
for (i=0;i<n;i++){
sel=i;
for (j=i+1;j<n;j++){
if (arr[sel]>arr[j])
sel=j;
}
printf("%d %d\n",i,sel);
a... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | 6c8ad54d512ce629a74d9cb53ab5885c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
int main()
{
int n, a[3001], b[3001], t, i, j, c = 0, x[3001], y[3001];
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &a[i]), b[i] = a[i];
for (i = 1; i < n; i++)
for (j = 0; j < n - 1; j++)
if (a[j] > a[j + 1])
t = a[j], a[j] = a[j + 1], a[j + 1] = t;
for (j = 0; j < n; j++)
... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | 53a348170747f1b4cda4c01714038a93 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
main()
{
int n,i,j,li,temp,swap=0,c=0;
scanf("%d",&n);
int a[n],x[n],y[n];
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++){
li=i;
for(j=i+1;j<n;j++){
if(a[j]<a[li]){
li=j;
}
}
if(li!=... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | f25d99c3d026a50929169404f7c23a3e | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
int main()
{
int n,z=0,res[3000][2],cnt=0;
scanf("%d",&n);
int ar[n];
for(int i=0;i<n;i++)
scanf("%d",&ar[i]);
for(int i=0;i<n;i++)
{
int j=i;
for(int t=i;t<n;t++)
{
if(ar[j]>ar[t])
j=t;
}
if(i!=j)
{
cnt++;
res[z][0]=i;
res[z++][... | |
In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.Note that in this problem you do not have to minimize the number of swap... | In the first line print k (0ββ€βkββ€βn) β the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0ββ€βi,βjββ€βnβ-β1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are per... | C | b3c6058893f935d88196113fab581cf8 | 6e045771d3274aa7de354516716c1f6c | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"implementation",
"sortings",
"greedy"
] | 1416238500 | ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100"] | null | PASSED | 1,200 | standard input | 1 second | The first line of the input contains integer n (1ββ€βnββ€β3000) β the number of array elements. The second line contains elements of array: a0,βa1,β...,βanβ-β1 (β-β109ββ€βaiββ€β109), where ai is the i-th element of the array. The elements are numerated from 0 to nβ-β1 from left to right. Some integers may appear in the arr... | ["2\n0 3\n4 2", "0", "1\n0 1"] | #include<stdio.h>
int main()
{
int ara[4000],fara[4000];
int n,i,j,k,a,b,c;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&ara[i]);
fara[i]=ara[i];
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(fara[j]<fara[i])
{
k=fa... | |
You are given two integers $$$a$$$ and $$$b$$$. Moreover, you are given a sequence $$$s_0, s_1, \dots, s_{n}$$$. All values in $$$s$$$ are integers $$$1$$$ or $$$-1$$$. It's known that sequence is $$$k$$$-periodic and $$$k$$$ divides $$$n+1$$$. In other words, for each $$$k \leq i \leq n$$$ it's satisfied that $$$s_{i}... | Output a single integerΒ β value of given expression modulo $$$10^{9} + 9$$$. | C | 607e670403a40e4fddf389caba79607e | 10e2ade1b7f605840a2b4965f28abe6e | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"number theory",
"math"
] | 1523973900 | ["2 2 3 3\n+-+", "4 1 5 1\n-"] | NoteIn the first example:$$$(\sum \limits_{i=0}^{n} s_{i} a^{n - i} b^{i})$$$ = $$$2^{2} 3^{0} - 2^{1} 3^{1} + 2^{0} 3^{2}$$$ = 7In the second example:$$$(\sum \limits_{i=0}^{n} s_{i} a^{n - i} b^{i}) = -1^{4} 5^{0} - 1^{3} 5^{1} - 1^{2} 5^{2} - 1^{1} 5^{3} - 1^{0} 5^{4} = -781 \equiv 999999228 \pmod{10^{9} + 9}$$$. | PASSED | 1,800 | standard input | 1 second | The first line contains four integers $$$n, a, b$$$ and $$$k$$$ $$$(1 \leq n \leq 10^{9}, 1 \leq a, b \leq 10^{9}, 1 \leq k \leq 10^{5})$$$. The second line contains a sequence of length $$$k$$$ consisting of characters '+' and '-'. If the $$$i$$$-th character (0-indexed) is '+', then $$$s_{i} = 1$$$, otherwise $$$s_{... | ["7", "999999228"] | #include <stdio.h>
typedef long long ll;
#define LEN 100005
#define MOD 1000000009
ll invMOD(ll x) {
if (x==1) return 1;
return (ll)(MOD-MOD/x)* invMOD(MOD % x)%MOD;
}
ll fastPOWMOD(ll a, ll x) {
ll ret=1;
while (x)
{
if (x&1) ret=(ll)ret*a%MOD;
a=(ll)a*a%MOD;
x>>=1;
}
return ret;
}
int main() {
int ... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 50c1788302877ae71ac940821ab69c78 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
#include <stdlib.h>
long long v[100002];
int main()
{
int n,d,i,j;
long long nr=0;
//freopen("p.in","r",stdin);
//freopen("p.out","w",stdout);
scanf("%d%d",&n,&d);
v[n+1]=10000000000LL;
for(i=1; i<=n; i++)
scanf("%I64d",&v[i]);
for(i=1; i<=n && v[i]-v[1]<d; i++... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 68a459cc9d4c4db9fc4c09f6a5765ff2 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
int main(void)
{
long long int N,d,pleft,pright,sum=0,pinakas[100005],count;
scanf("%I64d%I64d",&N,&d);
for(count=0;count<N;count++)
scanf("%I64d",&pinakas[count]);
for(pleft=0,pright=2;pleft<=N-3;){
while(llabs(pinakas[pleft]-pinakas[pright])<=d){
if(pright<N-1)
pright++;
else {... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | adee6b37823b259c2a264563da2908f3 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
int n,d;
long long ans,num[100010];
int main()
{
int i,j;
scanf("%d%d",&n,&d);
for(i=1;i<=n;i++) scanf("%I64d",&num[i]);
num[n+1] = 2100000000;
for(i=j=1;i<=n;i++)
{
while(num[j]-num[i]<=d) j++;
ans += (long long)(j-i-1)*(j-i-2)>>1;
}
printf("%I64d",ans... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 9860576d77442db1310254b4e8809c8e | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
int main()
{
int n,d,i=0,r=0;
scanf("%d %d",&n,&d);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
long long c=0,p=0;
for(i=0,r=0;i<n;i++)
{
while(r<n&&a[r]<=a[i]+d)
r++;
p=r-i-1;
c=c+(p*(p-1))/2;
}
printf("%I64d",c);
return 0;
}
| |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 64338fa2a1309b2e87a22cc29e16cbe5 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
typedef long long ll;
int x[100000];
void solve(int n, int d)
{
int l, r, m, i, p;
ll ans;
ans = 0;
for (i = 0; i < n - 2; i ++)
{
l = i;
r = n - 1;
p = -1;
while (l <= r)
{
m = (l + r) >> 1;
if (x[m] - x[i] <= d)
... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 1ccc4c96c6ccbb7948fedebae4a977da | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
int main()
{
int i,j,n,k,p;
__int64 t=0,t1=0,a[100001]={1};
scanf("%d %d",&n,&p);
scanf("%I64d",&a[1]);
for(i=2;i<=n;i++)
{
scanf("%I64d",&a[i]);
while((a[i]-a[a[0]])>p)a[0]++;
t+=((i-a[0])*(i-a[0]-1))/2;
}
printf("%I64d",t);
return 0;
} | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 8e12e77f15e26c8ed2a97280b9f5a75f | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
long long int result=0;int find_it_man(long long int key,long long int n,long long int positions[]){long long int low=0,high=n-1,medium=(low+high)/2,i,yes=0,s;for(i=0;i<n;i++){low=i+1,high=n-1,medium=(high+low)/2;for(;low<=high;){medium=(high+low)/2;if(positions[medium]==positions[i]+key){yes=1;break;... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 5aa5a2ca71a23294da1c6e43b454f655 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
long long s[100005];
int main()
{
long long n, d,start=0,ans=0,i,j;
scanf("%I64d%I64d", &n, &d);
for(i=0; i < n; ++i)
{
scanf("%I64d",&s[i]);
}
for(j=2; j <n; ++j)
{
while(s[j]-s[start] > d)
{
++start;
}
if(j-start-1 ... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | b8ba53eede93e861e95a1a50b8e9804a | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
typedef __int64 LL;
int A[100001];
int N,D;
int BinSearch(int i)
{
int Left=i,Right=N,Mid;
LL temp;
while(Right>Left)
{
Mid=(Left+Right)/2;
temp=A[Mid]-A[i];
if(temp>D)
{
Right=Mid-1;
}
else if(temp==D)
{
... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | f05e0c0ba8d64e6c6dee1637469d544b | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
typedef __int64 LL;
LL A[100001];
LL N,D;
int BinSearch(int i)
{
int Left=i,Right=N,Mid;
LL temp;
while(Right>Left)
{
Mid=(Left+Right)/2;
temp=A[Mid]-A[i];
if(temp>D)
{
Right=Mid-1;
}
else if(temp==D)
{
... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | e8a2a0ba24a6575d91b0bb75c475a4d6 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
#define N 100000
int main() {
int n,d;
scanf("%d%d",&n,&d);
int i;
int x[N];
for(i=0;i<n;i++){
scanf("%d",&x[i]);
}
if(n<3){
printf("0\n");
}else{
long long way=0;
for(i=2;i<n;i++){
//printf("i=%d\n",i);
//θΏιε―ΉδΊεζ³ηδ½Ώη¨ζ₯θͺ
int target=x[i]-d;
int left=0;
int right=i;
while(... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | a51e6dfaeb9e70615fd24546ea176ae5 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
int binaryL(int h,int n,int *a){
int beg=0,end=n-1,mid=(end+beg)/2;
while (beg<=end) {
if(a[mid]==h)
return mid;
if(a[mid]<h){
beg=mid+1;
}
... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 1a1fc00e3fb1a81d7ec21e14c7f15297 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
int binaryL(int h,int n,int *a){
int beg=0,end=n-1,mid=(end+beg)/2;
while (beg<=end) {
if(a[mid]==h)
return mid;
if(a[mid]<h){
beg=mid+1;
}
... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 4b76a159213c53971aaba87ccbb73127 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
#include<math.h>
long long int a[100001];
int ncr[100000][4]={0};
int bsearch(long long int x,int left,int right,long long d)
{
int mid;
while(left<right)
{
//printf("yes\n");
mid=(left+right+1)/2;
if((a[mid]-x)==d)
return mid;
if((a[mid]-x)<d)
... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 61abe488d10162b32930db2595a52525 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
int binary(int l, int r, int target, int arr[])
{
if ( l <= r )
{
int mid = (l+r)/2;
if ( arr[mid] <= target && arr[mid+1] > target )
return mid;
else if ( arr[mid] > target )
return binary(l, mid-1, target, arr);
else
retur... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 4a7f248f3f468b4db873790a1fe78ffb | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
int binary(int l, int r, int target, int arr[])
{
if ( l <= r )
{
int mid = (l+r)/2;
if ( arr[mid] <= target && arr[mid+1] > target )
return mid;
else if ( arr[mid] > target )
return binary(l, mid-1, target, arr);
else
retur... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | c787cbe0efb8012ffd0c0d516db63e91 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
int binary(int l, int r, long long target, long long arr[])
{
if ( l <= r )
{
int mid = (l+r)/2;
if ( arr[mid] <= target && arr[mid+1] > target )
return mid;
else if ( arr[mid] > target )
return binary(l, mid-1, target, arr);
else
... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 31a1930baaf6193a23463ea680be92b6 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
#include <string.h>
long long n, d;
long long i, j;
long long num[100005];
long long ans = 0;
long long find(long long start, long long i, long long j) {
long long mid;
while (i < j) {
mid = (i + j) / 2;
if (num[mid] - num[start] <= d) {
i = mid + 1;
}
else {
j = mid;
}
}
mid ... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 4fb39e3dc3e30d5c2be8997039f03b32 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
#define SIZE 100010
int main()
{
long long int n;
long long int d,a[SIZE];
scanf("%lld %lld",&n,&d);
long long int i,p1,p2;
long long int count1=0;
for(i=0;i<n;i++)
{
scanf("%lld",&a[i]);
}
p1=0;
p2=0;
while(p2<n)
{
if(a[p2]-a[p1]<=d)
{
count1+=(p2-p1)*(p2-p1-1)/2;
p2++;
}
... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 911da6b9fcbb7c0d16ad005807f50cf3 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
int po[100001];
int main(void)
{
int n, d, i, j;
long long w, tmp;
scanf("%d%d", &n, &d);
for(i = 0; i < n; i++)
scanf("%d", &po[i]);
w = 0;
i = 0;
j = i + 3;
for(; i <= n - 3; i++){
if(po[i+2] - po[i] > d){
j = i + 3;
continue;... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 3c8316abbc42d1dc43baa20fd01da939 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
#define sc(d) scanf("%I64d",&d);
long long nc2(long long n)
{
if(n<2) return 0ll;
return (n*(n-1))/(2ll);
}
int main()
{
long long n,d;
sc(n);sc(d);
long long a[n];
long long ans=0ll,i,j = 0ll;
for(i=0ll;i<n;i++)
sc(a[i]);
for(i=0ll;i<n;i++)
{
while(a[j+1]-a[i] <=d && j+1<n)
j++;
... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 3ffd3b791bc4113022b1a40e9dd78dca | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long int lint;
typedef unsigned long long int ulint;
#define N 100010
int a[N], seen[N];
int main() {
int n, i, d;
scanf("%d %d", &n, &d);
for(i=0; i<n; i++) scanf("%d", &a[i]);
memset(seen, 0, sizeof(seen));
lint ans = 0;
int x = 0, ... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | cd7ca068b63f51707d31112dcaa54407 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
typedef long long int lld;
int arr[100005],d;
lld sum=0;
int main()
{
int j=1,n,i,start;
scanf("%d%d",&n,&d);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
for(start=0;start<n-2;start++)//find last number satisfying the condition
{
while(j<n&&arr[j]-arr[start]<=d)
j++... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | e318a4fadafcf78d037074f86f0d161b | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef unsigned long long int lli;
lli solve(int a[], int n, int d, int idx) {
int st = idx;
int end = n - 1;
int key = a[idx]+d;
int mid, last;
int ct = 0;
// find ct such that a[ct]<=key && a[ct+1]>key
while (st <= end) {
mid = (st+end)/2;
if (a[... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 6f42fe49c5570ca962d39f9a5c3ae3ef | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include <stdio.h>
long long s[100005];
int main()
{
long long n, d,start=0,ans=0,i,j;
scanf("%I64d\t%I64d\n", &n, &d);
for(i=0; i < n; ++i)
{
scanf("%I64d",&s[i]);
}
for(j=2; j <n; ++j)
{
while(s[j]-s[start] > d)
{
++start;
}
if(j-start-1 ... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 953a560a3c47799f459937b9b69ece1c | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | long long num[100005];
main()
{
long long int resp=0,l=0,val,i,n,d;
scanf("%I64d %I64d",&n,&d);
for(i=0;i<n;i++)
scanf("%I64d",&num[i]);
for(i=0;i<n;i++)
{
val=num[i]+d;
for(;num[l]<=val && l<n;l++);
if(l-i>1)
resp+=(l-i-2)*(l-i-1)/2;
}
printf("%I6... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | feb283e043a3eb17a343e71fafd3a35c | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | long long num[100005];
main()
{
long long int resp=0,l=0,val,i,n,d;
scanf("%I64d %I64d",&n,&d);
for(i=0;i<n;i++)
scanf("%I64d",&num[i]);
for(i=0;i<n;i++)
{
val=num[i]+d;
for(;num[l]<=val && l<n;l++);
if(l-i>1)
resp+=(l-i-2)*(l-i-1)/2;
}
printf("%I6... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | eaa6d892bb6891d3181d425a6e1f6d64 | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
int main()
{
long long int n,ar[100009],x,d,tmp;
scanf("%lld%lld",&n,&d);
for(x=0;x<n;x++)
{
scanf("%lld",&ar[x]);
}
if(n<2)
{
printf("0\n");
return 0;
}
long long int st = 0,end = 0,ans = 0;
for(st=0;st<n-2;st++)
{
while(ar[end]-ar[st]<=d && end<n)
end++;
if(end == n)
end--... | |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.Note that the order of the points inside the group of three chosen points ... | Print a single integer β the number of groups of three points, where the distance between two farthest points doesn't exceed d. Please do not use the %lld specifier to read or write 64-bit integers in Π‘++. It is preferred to use the cin, cout streams or the %I64d specifier. | C | 1f6491999bec55cb8d960181e830f4c8 | 91f8b821f71afb4958ed5359120e581c | GNU C | standard output | 256 megabytes | train_001.jsonl | [
"combinatorics",
"binary search",
"two pointers"
] | 1354807800 | ["4 3\n1 2 3 4", "4 2\n-3 -2 -1 0", "5 19\n1 10 20 30 50"] | NoteIn the first sample any group of three points meets our conditions.In the seconds sample only 2 groups of three points meet our conditions: {-3, -2, -1} and {-2, -1, 0}.In the third sample only one group does: {1, 10, 20}. | PASSED | 1,300 | standard input | 2 seconds | The first line contains two integers: n and d (1ββ€βnββ€β105;Β 1ββ€βdββ€β109). The next line contains n integers x1,βx2,β...,βxn, their absolute value doesn't exceed 109 β the x-coordinates of the points that Petya has got. It is guaranteed that the coordinates of the points in the input strictly increase. | ["4", "2", "1"] | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main() {
int n, d, x[100005];
long long int ans=0;
scanf("%d%d", &n, &d);
for(int i=0; i<n; i++) scanf("%d", x+i);
for(int i=0, j=0; i<n; i++) {
while(x[i]-x[j]>d) j++;
ans+=(long long)(i-j)*(i-j-1)/2;
}
printf("%I6... | |
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any other inflorescence with number i (iβ>β1) is situated at the top of bra... | Single line of output should contain one integer number: amount of apples that Arcady will be able to collect from first inflorescence during one harvest. | C | a4563e6aea9126e20e7a33df664e3171 | b06f218e114bd9153a62952e7471ba45 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"dfs and similar",
"trees",
"graphs"
] | 1520177700 | ["3\n1 1", "5\n1 2 2 2", "18\n1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4"] | NoteIn first example Arcady will be able to collect only one apple, initially situated in 1st inflorescence. In next second apples from 2nd and 3rd inflorescences will roll down and annihilate, and Arcady won't be able to collect them.In the second example Arcady will be able to collect 3 apples. First one is one initi... | PASSED | 1,500 | standard input | 1 second | First line of input contains single integer number n (2ββ€βnββ€β100β000) Β β number of inflorescences. Second line of input contains sequence of nβ-β1 integer numbers p2,βp3,β...,βpn (1ββ€βpiβ<βi), where pi is number of inflorescence into which the apple from i-th inflorescence rolls down. | ["1", "3", "4"] | #define e(n) for(i=1;i<=n;i++)
n,p[1<<17],d[1<<17],s[1<<17],ans,i;
main(){
scanf("%d", &n);
e(n-1)scanf("%d",&p[i+1]);
e(n)s[d[i] = d[p[i]]+1]^=1;
e(n)ans += s[i];
printf("%d\n", ans);
} | |
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any other inflorescence with number i (iβ>β1) is situated at the top of bra... | Single line of output should contain one integer number: amount of apples that Arcady will be able to collect from first inflorescence during one harvest. | C | a4563e6aea9126e20e7a33df664e3171 | de8902f433a145134a4fa8aa0950102a | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"dfs and similar",
"trees",
"graphs"
] | 1520177700 | ["3\n1 1", "5\n1 2 2 2", "18\n1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4"] | NoteIn first example Arcady will be able to collect only one apple, initially situated in 1st inflorescence. In next second apples from 2nd and 3rd inflorescences will roll down and annihilate, and Arcady won't be able to collect them.In the second example Arcady will be able to collect 3 apples. First one is one initi... | PASSED | 1,500 | standard input | 1 second | First line of input contains single integer number n (2ββ€βnββ€β100β000) Β β number of inflorescences. Second line of input contains sequence of nβ-β1 integer numbers p2,βp3,β...,βpn (1ββ€βpiβ<βi), where pi is number of inflorescence into which the apple from i-th inflorescence rolls down. | ["1", "3", "4"] | #define e(n) for(i=0;++i<=n;)
n,p[1<<17],d[1<<17],s[1<<17],a,i;
main(){
scanf("%d", &n);
e(n-1)scanf("%d",&p[i+1]);
e(n)s[d[i]=d[p[i]]+1]++;
e(n)a+=s[i]&1;
printf("%d",a);
} | |
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any other inflorescence with number i (iβ>β1) is situated at the top of bra... | Single line of output should contain one integer number: amount of apples that Arcady will be able to collect from first inflorescence during one harvest. | C | a4563e6aea9126e20e7a33df664e3171 | c980324cdc72d45ab07ceb81a7fb8c44 | GNU C11 | standard output | 256 megabytes | train_001.jsonl | [
"dfs and similar",
"trees",
"graphs"
] | 1520177700 | ["3\n1 1", "5\n1 2 2 2", "18\n1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4"] | NoteIn first example Arcady will be able to collect only one apple, initially situated in 1st inflorescence. In next second apples from 2nd and 3rd inflorescences will roll down and annihilate, and Arcady won't be able to collect them.In the second example Arcady will be able to collect 3 apples. First one is one initi... | PASSED | 1,500 | standard input | 1 second | First line of input contains single integer number n (2ββ€βnββ€β100β000) Β β number of inflorescences. Second line of input contains sequence of nβ-β1 integer numbers p2,βp3,β...,βpn (1ββ€βpiβ<βi), where pi is number of inflorescence into which the apple from i-th inflorescence rolls down. | ["1", "3", "4"] | #define e(x) for(i=x;i<=n;i++)
n,p[1<<17],d[1<<17],s[1<<17],a,i;
main(){
scanf("%d", &n);
e(2)scanf("%d",&p[i]);
e(1)s[d[i]=d[p[i]]+1]^=1;
e(1)a+=s[i];
printf("%d",a);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.