結果
| 問題 |
No.1268 Fruit Rush 2
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-12-23 01:22:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 2,000 ms |
| コード長 | 570 bytes |
| コンパイル時間 | 2,206 ms |
| コンパイル使用メモリ | 206,756 KB |
| 最終ジャッジ日時 | 2025-02-18 13:28:57 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
ll N, ans=0;
cin >> N;
unordered_map<ll, ll> mp;
vector<ll> A(N);
//Nの作り方=(N-1が元からある時のみ)N-2の作り方
for (int i=0; i<N; i++){
cin >> A[i];
mp[A[i]]++;
}
sort(A.begin(), A.end());
for (auto x : A){
if (mp.count(x-1)) mp[x+1] += mp[x-1];
}
for (auto [x, y] : mp){
ans += y;
}
cout << ans << endl;
return 0;
}
srjywrdnprkt