結果

問題 No.182 新規性の虜
ユーザー 👑 CleyL
提出日時 2020-01-08 01:41:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 562 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 74,320 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-23 01:44:56
合計ジャッジ時間 2,120 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;cin>>n;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    vector<int> a(n);
    for(int i = 0; n > i; i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int ans = 0;
    for(int i = 0; n > i; i++){
        if(!i){
            if(a[i] != a[i+1])ans++;
        }else if(i == n-1){
            if(a[i-1] != a[i])ans++;
        }else{
            if(a[i-1] != a[i] && a[i] != a[i+1])ans++;
        }
    }
    cout << ans << endl;
}
0