Submission #433510

#TimeUsernameProblemLanguageResultExecution timeMemory
433510kiennguyen246Labels (NOI20_labels)C++14
100 / 100
108 ms6660 KiB
/**
 * \author Nguyen Duc Kien
 * \date 20/06/2021
 */

///Task name
#define TASK ""

///-------------------------------------------///

#include <bits/stdc++.h>

using namespace std;

const int maxn = 3e5 + 5;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cerr << "Processing...\n\n";
    if (fopen(TASK".INP", "r"))
    {
        freopen(TASK".INP", "r", stdin);
//        freopen(TASK".OUT", "w", stdout);
    }

    cin >> n;
    for (int i = 1; i < n; i ++) cin >> d[i];
    a[1] = 0;
    for (int i = 2; i <= n; i ++)
        a[i] = a[i - 1] + d[i - 1];
    int mn = *min_element(a + 1, a + n + 1);
    for (int i = 1; i <= n; i ++) a[i] += (1 - mn);
    mn = *min_element(a + 1, a + n + 1);
    int mx = *max_element(a + 1, a + n + 1);
    if (mx != n) cout << -1;
    else for (int i = 1; i <= n; i ++) cout << a[i] << " ";
    cerr << "\n\n-----------------\n";
    return 0;
}

Compilation message (stderr)

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