結果
問題 |
No.1268 Fruit Rush 2
|
ユーザー |
![]() |
提出日時 | 2020-10-17 16:46:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 324 ms / 2,000 ms |
コード長 | 491 bytes |
コンパイル時間 | 2,420 ms |
コンパイル使用メモリ | 203,664 KB |
最終ジャッジ日時 | 2025-01-15 10:57:35 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; set<ll> s; for (int i = 0; i < n; i++) { ll a; cin >> a; s.insert(a); } map<ll, ll> mp; ll ans = n; for (auto &f : s) { ll count = 0; if (s.find(f - 1) != s.end()) count++; if (mp.find(f - 1) != mp.end()) count += mp[f - 1]; mp[f + 1] = count; ans += count; } cout << ans << '\n'; }