結果

問題 No.1373 Directed Operations
ユーザー 夜
提出日時 2021-02-06 04:21:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 869 ms
コンパイル使用メモリ 98,428 KB
実行使用メモリ 4,416 KB
最終ジャッジ日時 2023-09-15 11:11:20
合計ジャッジ時間 4,040 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 147 ms
4,376 KB
testcase_03 AC 20 ms
4,384 KB
testcase_04 AC 32 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 164 ms
4,380 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 20 ms
4,380 KB
testcase_09 AC 38 ms
4,380 KB
testcase_10 AC 33 ms
4,376 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 32 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 174 ms
4,416 KB
testcase_15 AC 146 ms
4,380 KB
testcase_16 AC 167 ms
4,380 KB
testcase_17 AC 116 ms
4,376 KB
testcase_18 AC 68 ms
4,380 KB
testcase_19 AC 67 ms
4,376 KB
testcase_20 AC 92 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<pair<int, int>> a;
int ans[100010];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a1;
		cin >> a1;
		a.emplace_back(make_pair(a1, i));
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n - 1; i++) {
		ans[a[i].second] = (i + 2) - a[i].first;
		if (ans[a[i].second] <= 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	for (int i = 0; i < n - 1; i++) {
		cout << ans[i] << endl;
	}
}

0