답안 #311679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
311679 2020-10-10T23:38:44 Z MilosMilutinovic Labels (NOI20_labels) C++14
0 / 100
244 ms 46180 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
  }
  int sum = 0;
  vector<int> b;
  b.push_back(0);
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == 0) {
      cout << -1 << '\n';
      return 0;
    }
    sum += a[i];
    b.push_back(sum);
  }
  map<int, int> mp;
  for (int i = 0; i < n - 1; i++) {
    /*if (b[i] > n || mp[b[i]]) {
      cout << -1 << '\n';
      return 0;
    }*/
    mp[b[i]] = 1;
  }
  int st = n - *max_element(b.begin(), b.end());
  st = max(st, n);
  vector<int> ans;
  ans.push_back(st);
  for (int i = 0; i < n - 1; i++) {
    ans.push_back(ans.back() + a[i]);
  }
  map<int, int> cnt;
  for (int c : ans) {
    cnt[c]++;
  }
  int new_cnt = 0;
  for (int i = 1; i <= n; i++) {
    new_cnt += cnt[i];
  }
  if (new_cnt != n || cnt[n] == 0) {
    cout << -1 << '\n';
    return 0;
  }
  for (int c : ans) {
    cout << c << " ";
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 244 ms 46180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct