Submission #676489

#TimeUsernameProblemLanguageResultExecution timeMemory
676489penguin133Labels (NOI20_labels)C++17
100 / 100
170 ms7920 KiB
#include <bits/stdc++.h> using namespace std; int arr[300005]; int ans[300005]; int a[300005]; int main(){ int n; cin >> n; int cnt = 0,maxi = 0; for(int i=1;i<n;i++){ cin >> arr[i]; } int f = 0; for(int i=1;i<n;i++){ cnt += arr[i]; maxi = max(maxi, cnt); } ans[0] = n - maxi; a[n-maxi]++; for(int i=1;i<n;i++){ ans[i] = ans[i-1] + arr[i]; a[ans[i]]++; } if(a[1] == 0 || a[n] == 0){ cout << "-1"; exit(0); } for(int i=0;i<n;i++){ cout << ans[i] << " "; } }

Compilation message (stderr)

Labels.cpp: In function 'int main()':
Labels.cpp:13:6: warning: unused variable 'f' [-Wunused-variable]
   13 |  int f = 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...