結果
問題 | No.1268 Fruit Rush 2 |
ユーザー | totori_nyaa |
提出日時 | 2020-10-23 23:30:01 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 266 ms / 2,000 ms |
コード長 | 1,251 bytes |
コンパイル時間 | 2,364 ms |
コンパイル使用メモリ | 211,404 KB |
実行使用メモリ | 17,700 KB |
最終ジャッジ日時 | 2023-09-28 18:45:35 |
合計ジャッジ時間 | 8,577 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 2 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 |
testcase_10 | AC | 2 ms
4,384 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,376 KB |
testcase_13 | AC | 1 ms
4,376 KB |
testcase_14 | AC | 1 ms
4,384 KB |
testcase_15 | AC | 1 ms
4,380 KB |
testcase_16 | AC | 188 ms
14,076 KB |
testcase_17 | AC | 149 ms
12,612 KB |
testcase_18 | AC | 159 ms
13,092 KB |
testcase_19 | AC | 163 ms
12,996 KB |
testcase_20 | AC | 163 ms
12,904 KB |
testcase_21 | AC | 153 ms
12,652 KB |
testcase_22 | AC | 186 ms
14,368 KB |
testcase_23 | AC | 183 ms
14,232 KB |
testcase_24 | AC | 155 ms
13,048 KB |
testcase_25 | AC | 150 ms
12,792 KB |
testcase_26 | AC | 209 ms
17,384 KB |
testcase_27 | AC | 212 ms
17,380 KB |
testcase_28 | AC | 212 ms
17,632 KB |
testcase_29 | AC | 213 ms
17,636 KB |
testcase_30 | AC | 218 ms
17,700 KB |
testcase_31 | AC | 266 ms
17,440 KB |
testcase_32 | AC | 263 ms
17,440 KB |
testcase_33 | AC | 225 ms
17,412 KB |
testcase_34 | AC | 177 ms
17,512 KB |
testcase_35 | AC | 195 ms
17,380 KB |
ソースコード
// #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' #define all(x) (x).begin(),(x).end() template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;} template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;} int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0}; long double eps = 1e-9; long double pi = acos(-1); signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); ll n; cin>>n; ll a[n]; map<ll,ll> mp; for(int i=0;i<n;i++){ cin>>a[i]; mp[a[i]] = 1; } sort(a,a+n); ll ans = n; auto itr = mp.end(); while(itr != mp.begin()){ itr--; ll nx = itr->first + 2; if(mp.count(nx)){ mp[nx-2] += mp[nx]; } } for(int i=1;i<n;i++){ if(a[i]-1 == a[i-1]){ ans += mp[a[i]]-1; } } ll cnt = 1; for(int i=1;i<n;i++){ if(a[i]-1 == a[i-1])cnt++; else { ans += cnt - 1; cnt = 1; } } ans += cnt - 1; cout << ans << endl; }