Submission #1574587
Source Code Expand
#include<bits/stdc++.h> using namespace std; void rd(int &x){ int k, m=0; x=0; for(;;){ k = getchar_unlocked(); if(k=='-'){ m=1; break; } if('0'<=k&&k<='9'){ x=k-'0'; break; } } for(;;){ k = getchar_unlocked(); if(k<'0'||k>'9'){ break; } x=x*10+k-'0'; } if(m){ x=-x; } } void wt_L(int x){ char f[10]; int m=0, s=0; if(x<0){ m=1; x=-x; } while(x){ f[s++]=x%10; x/=10; } if(!s){ f[s++]=0; } if(m){ putchar_unlocked('-'); } while(s--){ putchar_unlocked(f[s]+'0'); } } int N, cnt[100001]; int main(){ int i, j, res; rd(N); for(i=0;i<N;i++){ rd(j); cnt[j]++; } { int KL2GvlyY=0, Lj4PdHRW, Q5VJL1cS, e98WHCEY; for(Lj4PdHRW=1;Lj4PdHRW<(100000-1)+1;Lj4PdHRW++){ e98WHCEY = cnt[Lj4PdHRW-1]+cnt[Lj4PdHRW]+cnt[Lj4PdHRW+1]; if(KL2GvlyY==0 || Q5VJL1cS<e98WHCEY){ Q5VJL1cS = e98WHCEY; KL2GvlyY = 1; } } res =Q5VJL1cS; } wt_L(res); putchar_unlocked('\n'); return 0; } // cLay varsion 20170628-1 [beta] // --- original code --- // int N, cnt[100001]; // { // int i, j; // int res; // rd(N); // rep(i,N) rd(j), cnt[j]++; // res = max[k=1---1d5-1](cnt[k-1]+cnt[k]+cnt[k+1]); // wt(res); // }
Submission Info
Submission Time | |
---|---|
Task | C - Together |
User | LayCurse |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1301 Byte |
Status | AC |
Exec Time | 3 ms |
Memory | 640 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 | 2 ms | 256 KB |
1_005.txt | AC | 3 ms | 256 KB |
1_006.txt | AC | 3 ms | 256 KB |
1_007.txt | AC | 3 ms | 256 KB |
1_008.txt | AC | 3 ms | 640 KB |