Submission #85410

# Submission time Handle Problem Language Result Execution time Memory
85410 2018-11-19T19:47:42 Z farukkastamonuda Nice sequence (IZhO18_sequence) C++14
0 / 100
20 ms 2216 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 400105
using namespace std;
int t,n,m,B[li];
int main(){
	scanf("%d",&t);
	while(t--){
		scanf("%d %d",&n,&m);// n negative , m positive
		if(n==m){
			printf("0\n\n");
			continue;
		}
		if(n==1){
			printf("%d\n",m-1);
			for(int i=1;i<=m-1;i++){
				printf("-1 ");
			}
			printf("\n");
			continue;
		}
		if(m==1){
			printf("%d\n",n-1);
			for(int i=1;i<=n-1;i++){
				printf("1 ");
			}
			printf("\n");
			continue;
		}
		if(n<m){
			for(int i=1;i<=400000;i++){
				if(i%n==0){
					B[i]=-((n-1)*10+1);
				}
				else B[i]=10;
			}
			int sum=0;
			for(int i=1;i<=m;i++){
				sum+=B[i];
			}
			if(sum<=0){
				printf("0\n\n");
				continue;
			}
			int say=m;
			for(int i=m+1;i<=400000;i++){
				sum-=B[i-m];
				sum+=B[i];
				if(sum<=0) break;
				say++;
			}
			printf("%d\n",say);
			for(int i=1;i<=say;i++){
				printf("%d ",B[i]);
			}
			printf("\n");
		}
		else{
			for(int i=1;i<=400000;i++){
				if(i%m==0){
					B[i]=((m-1)*10+1);
				}
				else B[i]=-10;
			}
			int sum=0;
			for(int i=1;i<=n;i++){
				sum+=B[i];
			}
			if(sum>=0){
				printf("0\n\n");
				continue;
			}
			int say=n;
			for(int i=n+1;i<=400000;i++){
				sum-=B[i-n];
				sum+=B[i];
				if(sum<=0) break;
				say++;
			}
			printf("%d\n",say);
			for(int i=1;i<=say;i++){
				printf("%d ",B[i]);
			}
			printf("\n");
		}
	}
	return 0;
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&t);
  ~~~~~^~~~~~~~~
sequence.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&m);// n negative , m positive
   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Incorrect 5 ms 2048 KB Jury has the better answer : jans = 86, pans = 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 2048 KB Jury has the better answer : jans = 1, pans = 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2084 KB Ok
2 Correct 2 ms 2084 KB Ok
3 Incorrect 17 ms 2208 KB Jury has the better answer : jans = 5, pans = 0
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 2216 KB Jury has the better answer : jans = 3, pans = 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Incorrect 5 ms 2048 KB Jury has the better answer : jans = 86, pans = 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Incorrect 5 ms 2048 KB Jury has the better answer : jans = 86, pans = 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Ok
2 Incorrect 5 ms 2048 KB Jury has the better answer : jans = 86, pans = 0
3 Halted 0 ms 0 KB -