結果

問題 No.1686 Geschenkt
ユーザー Xalei
提出日時 2021-09-29 00:19:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 353 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 172,376 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-08 10:34:08
合計ジャッジ時間 2,088 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define print(n) cout << n << endl;
int main(){
    int N;cin >> N;vector<int> A(N);
    rep(i,N)cin >> A[i];
    sort(A.begin(),A.end());
    int ans = 0;
    rep(i,N-1)if(A[i+1] != A[i] + 1)ans += A[i+1];
    ans += A[0];
    cout << ans << endl;
}
    
0