結果

問題 No.1686 Geschenkt
コンテスト
ユーザー noya2
提出日時 2021-07-18 17:50:14
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 523 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,425 ms
コンパイル使用メモリ 335,780 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-21 19:49:00
合計ジャッジ時間 7,040 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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