結果

問題 No.1285 ゴミ捨て
ユーザー tadanoningentadanoningen
提出日時 2020-11-13 22:46:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 1,101 ms
コンパイル使用メモリ 94,600 KB
最終ジャッジ日時 2025-01-15 23:43:40
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    bool odd = false;
    bool even = false;
    bool plus1 = false;
    vector<int> a(n);
    int memo = 0;
    for(int i=0;i < n;i++){
        cin >> a[i];
        if(a[i] % 2 == 0) even = true;
        else odd = true;
    }
    
    sort(a.begin(),a.end());
    
    for(int i=0;i < n-1;i++){
        if(abs(a[i]-a[i+1]) == 1) plus1 = true;
    }
    if(n == 1) cout << 1 << endl;
    else{
        if(odd && even && plus1) cout << 2 << endl;
        else cout << 1 << endl;
    }
    return 0;
}
0