Submission #1558834
Source Code Expand
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<stack> #include<queue> #include<vector> #include<algorithm> #include<iomanip> #include<utility> typedef long long int ll; using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define REP(i,n) for (int i=0;i<signed(n);i++) #define EREP(i,n) for (int i=1;i<=(n);i++) #define ALL(a) (a).begin(),(a).end() //#define EVEL 1 #ifdef EVEL #define DEB(X) cout << #X << ":" <<X<<" " ; #define TF(f) f ? cout<<"true " : cout<<"false "; #define END cout<<"\n"; #else #define DEB(X) {} #define TF(f) {} #define END {} #endif const int MOD = 1000000007; const ll INF = 200000000000; struct edge {int to,cost;}; typedef std::pair<int,int> P; ll N; int A[100010]; int C[100010]; ll ans=0; int main(){ ios_base::sync_with_stdio(false); cin>>N; REP(i,N){ cin>>A[i]; C[A[i]]++; } ll temp=0; REP(i,100001){ if(i<=2){ temp+=C[i]; if(i==2)ans=temp; }else{ temp+=C[i]; temp-=C[i-3]; ans=max(ans,temp); } } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Together |
User | Nafmo2 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1236 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 1024 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
1_003.txt | AC | 1 ms | 256 KB |
1_004.txt | AC | 7 ms | 640 KB |
1_005.txt | AC | 9 ms | 640 KB |
1_006.txt | AC | 9 ms | 640 KB |
1_007.txt | AC | 9 ms | 640 KB |
1_008.txt | AC | 10 ms | 1024 KB |