Submission #466923

#TimeUsernameProblemLanguageResultExecution timeMemory
466923AMO5Labels (NOI20_labels)C++17
100 / 100
85 ms6672 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define ld long double #define all(x) x.begin(),x.end() #define sz(x) (int)x.size() #define dbg if(0) #define BUG(x) dbg cerr << (#x) << " is " << (x) << endl const int mxn = (int)3e5+5; void solve(){ int n; cin>>n; vector<int>a(n), d(n-1); for(auto &x:d)cin>>x; a[0]=1; int mn = a[0]; for(int i=0; i<n-1; i++){ a[i+1]=a[i]+d[i]; mn = min(mn,a[i+1]); } int diff = 1-mn; mn = n+1; int mx=0; for(int i=0; i<n; i++){ a[i]+=diff; if(a[i]>n){ cout<<-1<<"\n"; return; } mn = min(mn,a[i]); mx = max(mx,a[i]); } if(mn!=1||mx!=n){ cout<<-1<<"\n"; return; } for(int i=0; i<n; i++) cout<<a[i]<<" \n"[i==n-1]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int t=1; cin>>t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...