Submission #1591606


Source Code Expand

    #include <bits/stdc++.h>
     
    #define REP(i, n) for(int i = 0; i < (int)(n); ++i)
    #define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
    #define INF 2000000000
     
    #ifdef LOCAL
      #define eprintf(...) fprintf(stdout, __VA_ARGS__)
    #else
      #define eprintf(...) 0
    #endif
     
    using namespace std;
     
    typedef long long LL;
    typedef unsigned long long ULL;
    typedef unsigned int uint;
     
    std::vector<std::string> split(const std::string &str, char delim) {
      std::istringstream stream(str);
      std::string element;
      std::vector<std::string> result;
      while(std::getline(stream, element, delim)) {
        result.push_back(element);
      }
      return result;
    }
     
    int main() {
      //const int x_max = 100000;
     
      uint n;
      string str;
      scanf("%u", &n);
      vector<int> nums;
      int a;
      REP(i, n) {
        scanf("%d", &a);
        nums.push_back(a);
      }
      /*
      getchar();
      getline(cin, str);
      vector<string> strnums = split(str, ' ');
      //REP(i, strnums.size()) { cout<<strnums[i]<<endl; }
      vector<int> nums;
      REP(i, strnums.size()) {
        nums.push_back(atoi(strnums[i].c_str()));    
      }
      */
      //REP(i, nums.size()) { cout<<nums[i]<<endl; }
      
      map<int, int> m;
     
      for(auto &x : nums) {
        m[x-1]++;
        m[x+1]++;
        m[x]++;
      }
      int ans = 0;
      for(auto &x : m) {
        ans = max(ans, x.second);
      }
      cout << ans;
     
      return 0;
    }

Submission Info

Submission Time
Task C - Together
User yoshi_k
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1635 Byte
Status AC
Exec Time 65 ms
Memory 5112 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
       scanf("%u", &n);
                      ^
./Main.cpp:38:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
                        ^

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 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 10 ms 892 KB
1_005.txt AC 12 ms 892 KB
1_006.txt AC 12 ms 892 KB
1_007.txt AC 17 ms 892 KB
1_008.txt AC 65 ms 5112 KB