Submission #1300115

#TimeUsernameProblemLanguageResultExecution timeMemory
1300115thdh__Labels (NOI20_labels)C++20
0 / 100
1 ms568 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define ii pair<int, int> #define fi first #define se second #define all(a) a.begin(), a.end() using namespace std; const int N = 3e5+5; const int mod = 1e9+7; const int inf = 2e9; void solve() { int n; cin>>n; vector<int> a(n, 0); for (int i = 1; i < n; i++) cin>>a[i]; for (int i = 2; i < n; i++) a[i] += a[i-1]; int mx = -inf, mn = inf; for (int i = 1; i < n; i++) mx = max(mx, a[i]), mn = min(mn, a[i]); int cnt = 0, ss = -1; for (int st = 1; st <= n; st++) { if (st + mx <= n && st + mn >= 1) cnt++, ss = st; } if (!cnt || cnt > 1) { cout<<"-1"; return; } for (int i = 0; i < n; i++) { cout<<ss + a[i]<<" "; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); solve(); }

Compilation message (stderr)

Labels.cpp: In function 'int main()':
Labels.cpp:43:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Labels.cpp:44:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...