結果

問題 No.1686 Geschenkt
ユーザー karaagekaraage
提出日時 2021-09-24 21:25:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,032 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 168,996 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 20:35:47
合計ジャッジ時間 2,237 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
const ll MOD=1000000000+7;
#define rep(I,N) for(int I=0;I<N;I++)
#define ALL(x) x.begin(),x.end()
#define PRINTV(x) for(auto i:x){for(auto j:i){printf("%d\t",j);}printf("\n");}
using vec = vector<int>;
using vvec = vector<vector<int>>;

ll lcm(ll a,ll b){
    return a/__gcd(a,b)*b;
}

template<class T>
void HorRot(vector<vector<T>>& v){
    for(int i=0;i<v.size()/2;i++){
        v[i].swap(v[v.size()-i-1]);
    }
}

template<class T>
void DiaRot(vector<vector<T>>& v){
    for(int i=0;i<v.size()-1;i++){
        for(int j=i+1;j<v.size();j++){
            swap(v[i][j],v[j][i]);
        }
    }
}

template<class T>
void Rot90(vector<vector<T>>& v){
    HorRot(v);
    DiaRot(v);
}

int main(){
    int n;
    cin >> n;
    vec a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    int sum=a[0];

    for(int i=1;i<n;i++){
        if(a[i]-1!=a[i-1]){
            sum+=a[i];
        }
    }
    
    printf("%d\n",sum);
}
0