Submission #1300091

#TimeUsernameProblemLanguageResultExecution timeMemory
1300091nathan4690Labels (NOI20_labels)C++20
100 / 100
36 ms7108 KiB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f1(i,n) for(int i=1;i<=n;i++)
#define __file_name ""
using namespace std;
const ll maxn=1e6+5, inf=1e18;

ll n, d[maxn], a[maxn];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if(fopen(__file_name ".inp", "r")){
        freopen(__file_name ".inp", "r", stdin);
        freopen(__file_name ".out", "w", stdout);
    }
    // code here
    cin >> n;
    f1(i,n-1) cin >> d[i];
    for(int i = 2; i <= n; i++){
        a[i] = a[i-1] + d[i-1];
    }
    if((*max_element(a+1,a+n+1)) - (*min_element(a+1,a+n+1)) == n - 1){
        a[1] = -(*min_element(a+1,a+n+1)) + 1;
        for(int i = 2; i <= n; i++) a[i] += a[1];
        f1(i,n) cout << a[i] << ' ';
        cout << '\n';
    }else{
        cout << "-1\n";
    }
    return 0;
}

Compilation message (stderr)

Labels.cpp: In function 'int main()':
Labels.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen(__file_name ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Labels.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(__file_name ".out", "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...