AtCoder Regular Contest 082

Submission #1591606

Source codeソースコード

    #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

Task問題 C - Together
User nameユーザ名 yoshi_k
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 300
Source lengthソースコード長 1635 Byte
File nameファイル名
Exec time実行時間 65 ms
Memory usageメモリ使用量 5112 KB

Compiler messageコンパイルメッセージ

./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);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_000.txt,0_001.txt,0_002.txt
All 300 / 300 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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