Submission #1360160

#TimeUsernameProblemLanguageResultExecution timeMemory
1360160lyra_g13Labels (NOI20_labels)C++20
7 / 100
15 ms6880 KiB
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  ll n;
  cin >> n;

  vector<ll> d(n - 1);
  for (auto &i : d) {
    cin >> i;
  }

  vector<ll> a(n);

  if (n == 2) {
    if (d[0] == 0)
      cout << -1 << "\n";
    else if (d[0] == 1)
      cout << "1 2" << "\n";
    else if (d[0] == -1)
      cout << "2 1" << "\n";

    return 0;
  }
  ll check = 0;
  for (int i = 1; i <= n; i++) {
    a[0] = i;
    for (int j = 1; j < n and check == 0; j++) {
      a[j] = a[j - 1] + d[j - 1];
      if (a[j] >= 1 and a[j] <= n)
        continue;
      else
        check = 1;
    }
    if (check != 1) {
      for (auto i : a) {
        cout << i << " ";
      }
      return 0;
    }
  }
  cout << -1 << "\n";
  return 0;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...