結果

問題 No.1373 Directed Operations
ユーザー risujirohrisujiroh
提出日時 2021-02-05 21:44:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,915 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 203,344 KB
実行使用メモリ 4,400 KB
最終ジャッジ日時 2023-09-15 07:33:32
合計ジャッジ時間 5,328 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 15 ms
4,380 KB
testcase_03 AC 9 ms
4,380 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 23 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 18 ms
4,400 KB
testcase_10 AC 16 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 15 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#pragma region my_template

struct Rep {
  struct I {
    int i;
    void operator++() { ++i; }
    int operator*() const { return i; }
    bool operator!=(I o) const { return i < *o; }
  };
  const int l_, r_;
  Rep(int l, int r) : l_(l), r_(r) {}
  Rep(int n) : Rep(0, n) {}
  I begin() const { return {l_}; }
  I end() const { return {r_}; }
};
struct Per {
  struct I {
    int i;
    void operator++() { --i; }
    int operator*() const { return i; }
    bool operator!=(I o) const { return i > *o; }
  };
  const int l_, r_;
  Per(int l, int r) : l_(l), r_(r) {}
  Per(int n) : Per(0, n) {}
  I begin() const { return {r_ - 1}; }
  I end() const { return {l_ - 1}; }
};

template <class F>
struct Fix : private F {
  Fix(F f) : F(f) {}
  template <class... Args>
  decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class T = int>
T scan() {
  T res;
  std::cin >> res;
  return res;
}

template <class T, class U = T>
bool chmin(T& a, U&& b) {
  return b < a ? a = std::forward<U>(b), true : false;
}
template <class T, class U = T>
bool chmax(T& a, U&& b) {
  return a < b ? a = std::forward<U>(b), true : false;
}

#ifndef LOCAL
#define DUMP(...) void(0)
template <int OnlineJudge, int Local>
constexpr int OjLocal = OnlineJudge;
#endif

using namespace std;

#define ALL(c) begin(c), end(c)

#pragma endregion

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n = scan();
  vector<int> a(n - 1);
  generate(ALL(a), scan<>);
  sort(ALL(a));
  vector<int> ans(n - 1);
  for (int i : Rep(1, n)) {
    if (a[i - 1] > i) {
      cout << "NO\n";
      exit(0);
    }
    ans[i - 1] = i - a[i - 1] + 1;
  }
  cout << "YES\n";
  for (auto&& e : ans) cout << e << '\n';
}
0