結果

問題 No.1686 Geschenkt
ユーザー noya2noya2
提出日時 2021-07-18 17:50:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 7,175 ms
コンパイル使用メモリ 307,596 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 20:23:53
合計ジャッジ時間 7,967 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"
#include<bits/stdc++.h>
using namespace std;

int main(){
	registerValidation();
	int n = inf.readInt(1,33,"n");
	inf.readEoln();
	vector<int> ar(n);
	for (int i = 0; i < n ; i++){
	    int c = inf.readInt(3,35,"c");
	    ar[i] = c;
	    if (i == n-1) inf.readEoln();
	    else inf.readSpace();
	}
	sort(ar.begin(),ar.end());
	int ans = ar[0];
	for (int i = 1; i < n; i++){
	    assert(ar[i-1] < ar[i]);
	    if (ar[i-1] + 1 != ar[i]) ans += ar[i];
	}
	cout << ans << endl;
	inf.readEof();
	return 0;
}
0