結果
問題 |
No.1268 Fruit Rush 2
|
ユーザー |
![]() |
提出日時 | 2020-05-31 15:46:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 694 bytes |
コンパイル時間 | 1,394 ms |
コンパイル使用メモリ | 169,972 KB |
実行使用メモリ | 11,932 KB |
最終ジャッジ日時 | 2024-06-22 07:43:14 |
合計ジャッジ時間 | 6,609 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 RE * 9 TLE * 1 -- * 4 |
ソースコード
// 愚直が撃墜されるか確認 #include <bits/stdc++.h> using namespace std; #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> exist(2e5, false); for (int i = 0; i < n; i++) { int a; cin >> a; exist.at(a - 1) = true; } ll ans = n; // 1個だけ選ぶとき for (int i = 1; i < 2e5; i++) { if (exist.at(i - 1) && exist.at(i)) { ll cnt = 1, it = i; while (it < 2e5 - 2 && exist.at(it + 2)) { cnt++; it += 2; } ans += cnt; } } cout << ans << '\n'; }