Submission #383400

# Submission time Handle Problem Language Result Execution time Memory
383400 2021-03-29T20:13:14 Z MODDI Labels (NOI20_labels) C++14
0 / 100
52 ms 3808 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
using namespace std;
int main(){
	int n;
	cin>>n;
	vi d,pref(n), ori;
	for(int i = 0; i < n-1; i++){
		int a;
		cin>>a;
		d.pb(a);
	}
	int sm;
	for(int i = 1; i < n; i++){
		pref[i] = pref[i - 1] + d[i - 1];
		mnto(sm, pref[i]);
	}
	int mx = 0;
	for(int i = 0; i <n; i++){
		pref[i]-=sm;
		mxto(mx, pref[i]);
	}
	if(mx != n - 1)
		cout<<-1<<endl;
	else
	{
		for(int i = 0; i < n; i++)
			cout<<pref[i] + 1<<" ";
	}
	return 0;
}

Compilation message

Labels.cpp: In function 'int main()':
Labels.cpp:28:10: warning: 'sm' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |   pref[i]-=sm;
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 3808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct