結果
問題 | No.1268 Fruit Rush 2 |
ユーザー |
![]() |
提出日時 | 2020-10-23 23:17:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 202 ms / 2,000 ms |
コード長 | 369 bytes |
コンパイル時間 | 798 ms |
コンパイル使用メモリ | 62,164 KB |
実行使用メモリ | 29,952 KB |
最終ジャッジ日時 | 2024-07-21 13:09:21 |
合計ジャッジ時間 | 5,450 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <stdio.h>#include <algorithm>#include <map>std::map<long long int,int> M;long long int x[200010];int main(){int a;scanf("%d",&a);for(int i=1;i<=a;i++) scanf("%lld",&x[i]);std::sort(x+1,x+a+1);long long int ans = 0;for(int i=a;i>=1;i--){if(M.find(x[i]+1)!=M.end()) ans += M[x[i]+1];M[x[i]] = M[x[i]+2]+1;}printf("%lld",ans+a);}