結果
| 問題 |
No.1268 Fruit Rush 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-24 01:55:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 389 bytes |
| コンパイル時間 | 728 ms |
| コンパイル使用メモリ | 69,880 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-21 14:47:00 |
| 合計ジャッジ時間 | 3,923 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long A[2<<17];
long ans;
int cnt[2<<17];
main()
{
cin>>N;
for(int i=0;i<N;i++)cin>>A[i];
sort(A,A+N);
for(int i=N;i--;)
{
if(A[i+1]==A[i]+2)cnt[i]=cnt[i+1]+1;
else if(A[i+2]==A[i]+2)cnt[i]=cnt[i+2]+1;
else cnt[i]=1;
}
for(int i=0;i<N;i++)
{
ans++;
if(A[i]+1==A[i+1])ans+=cnt[i+1];
}
cout<<ans<<endl;
}