# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
344869 | Jarif_Rahman | Labels (NOI20_labels) | C++17 | 74 ms | 6892 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
vector<int> v(n-1);
for(int &x: v) cin >> x;
int mx = 0, mn = 1e8;
int cur = 0;
for(int i = 0; i < n-1; i++) cur+=v[i], mx = max(mx, cur), mn = min(mn, cur);
bool bl = 1;
int c = n - mx;
vector<int> ans(n);
ans[0] = c;
for(int i = 1; i < n; i++) ans[i] = ans[i-1] + v[i-1];
bool o = 0, nn = 0;
for(int i = 0; i < n; i++){
if(ans[i] == 1) o = 1;
if(ans[i] == n) nn = 1;
}
if(!o || !nn){
cout << "-1\n";
exit(0);
}
for(int x: ans) cout << x << " ";
cout << "\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |