結果
問題 | No.1268 Fruit Rush 2 |
ユーザー |
|
提出日時 | 2020-10-23 22:53:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 661 bytes |
コンパイル時間 | 1,594 ms |
コンパイル使用メモリ | 172,452 KB |
実行使用メモリ | 13,880 KB |
最終ジャッジ日時 | 2024-07-21 12:03:48 |
合計ジャッジ時間 | 6,450 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 TLE * 1 -- * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr char newl = '\n'; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); ll ans = n; for (int i = 1; i < n; i++) { if (a[i] - a[i - 1] != 1) continue; ll cur = a[i]; ++ans; for (int j = i + 1; j < n; j++) { if (a[j] > cur + 2) break; if (a[j] < cur + 2) continue; cur += 2; ++ans; } } cout << ans << newl; return 0; }