Submission #2251954


Source Code Expand

// ------------------------------------
// Date:2018/ 3/25
// Problem:C - Together b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1e5 + 101;

int N;

ll cnt[MAX_N];

int main()
{
  fill_n(cnt, MAX_N, 0);
  scanf("%d", &N);
  vector< int > a(N);
  REP(i, N) {
    scanf("%d", &a[i]);
    if (a[i] > 0) cnt[a[i] - 1]++;
    cnt[a[i]]++;
    cnt[a[i] + 1]++;
  }

  ll ans = -1ll;
  REP(i, MAX_N) {
    ans = max(ans, cnt[i]);
  }

  cout << ans << endl; 
  
  return 0;
}

Submission Info

Submission Time
Task C - Together
User task4233
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1282 Byte
Status AC
Exec Time 11 ms
Memory 1408 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
                  ^
./Main.cpp:43:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a[i]);
                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 9
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 2 ms 1024 KB
0_001.txt AC 2 ms 1024 KB
0_002.txt AC 2 ms 1024 KB
1_003.txt AC 2 ms 1024 KB
1_004.txt AC 9 ms 1408 KB
1_005.txt AC 11 ms 1408 KB
1_006.txt AC 11 ms 1408 KB
1_007.txt AC 11 ms 1408 KB
1_008.txt AC 11 ms 1408 KB