Submission #29563

#TimeUsernameProblemLanguageResultExecution timeMemory
29563undecember사냥꾼 (KOI13_hunter)C++14
100 / 100
86 ms2392 KiB
#include <bits/stdc++.h> using namespace std; int m, n, l; vector<int> shr; int main(void) { int n; scanf("%d%d%d", &m, &n, &l); shr.assign(m, 0); int i; for (int i = 0; i < m; i++) scanf("%d", &shr[i]); sort(shr.begin(), shr.end()); int ans = 0; for (int i = 0; i < n; i++) { int a, b; scanf("%d%d", &a, &b); int j = lower_bound(shr.begin(), shr.end(), a) - shr.begin(); if (j < 0) j = 0; else if (j >= shr.size()) j = shr.size() - 1; else { if (j != shr.size() - 1) if (abs(a - shr[j]) > abs(a - shr[j + 1])) j++; if (j != 0) if (abs(a - shr[j]) > abs(a - shr[j - 1])) j--; } int dst = abs(shr[j] - a) + b; if (dst <= l) ans++; } printf("%d", ans); return 0; }

Compilation message (stderr)

hunter.cpp: In function 'int main()':
hunter.cpp:26:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   else if (j >= shr.size()) j = shr.size() - 1;
              ^
hunter.cpp:29:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (j != shr.size() - 1)
          ^
hunter.cpp:14:6: warning: unused variable 'i' [-Wunused-variable]
  int i;
      ^
hunter.cpp:11:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &m, &n, &l);
                             ^
hunter.cpp:15:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0; i < m; i++) scanf("%d", &shr[i]);
                                                  ^
hunter.cpp:22:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...