結果

問題 No.1686 Geschenkt
ユーザー LV3zJigVW57oPGy
提出日時 2022-08-17 14:16:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 1,108 ms
コンパイル使用メモリ 163,152 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-04 15:41:20
合計ジャッジ時間 1,554 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int a;
  cin >>a;
  int b, c;
  c=0;
  vector<int> vec(a);
  for(int  i=0; i<a; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<a-1; i++){
    if(vec.at(i+1) - 1 != vec.at(i)){
     c += vec.at(i+1);
    }
  }
 // if(vec.at(1)-1 !=vec.at(0)){
   // c+=vec.at(0);
  //}
  cout << c + vec.at(0);
}
 /*for(int i=0; i<a; i++){
   cout << vec.at(i) <<endl;
 }*/
0