Submission #936607

#TimeUsernameProblemLanguageResultExecution timeMemory
936607vjudge1Labels (NOI20_labels)C++17
100 / 100
107 ms6740 KiB
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int d[n-1]; for(int i = 0;i<n-1;i++)cin>>d[i]; int a[n]; a[0]=0; int idx = 0; for(int i = 0;i<n-1;i++){ a[i+1]=a[i]+d[i]; if(a[i+1]>a[idx])idx=i+1; } a[idx]=n; int mn = n; for(int i = idx+1;i<n;i++){ a[i]=a[i-1]+d[i-1]; mn=min(mn,a[i]); } for(int i = idx-1;i>=0;i--){ a[i]=a[i+1]-d[i]; mn=min(mn,a[i]); } if(mn!=1){ cout<<-1; return 0; } for(int i = 0;i<n;i++)cout<<a[i]<<" "; }
#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...