結果

問題 No.1686 Geschenkt
ユーザー shojin
提出日時 2024-05-05 15:34:05
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 283 bytes
コンパイル時間 3,461 ms
コンパイル使用メモリ 280,288 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 14:01:17
合計ジャッジ時間 4,059 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(auto &x : A) cin >> x;
  sort(A.begin(), A.end());
  
  int ans = A[0];
  for(int i = 0; i < N - 1; i++){
    if(A[i + 1] - A[i] > 1) ans += A[i + 1];
  }
  
  cout << ans;
}
0