답안 #27404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27404 2017-07-12T12:19:46 Z undecember 사냥꾼 (KOI13_hunter) C++14
100 / 100
89 ms 2392 KB
#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

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);
                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 2212 KB Output is correct
2 Correct 53 ms 2308 KB Output is correct
3 Correct 69 ms 2344 KB Output is correct
4 Correct 53 ms 2248 KB Output is correct
5 Correct 76 ms 2312 KB Output is correct
6 Correct 79 ms 2376 KB Output is correct
7 Correct 76 ms 2384 KB Output is correct
8 Correct 56 ms 2200 KB Output is correct
9 Correct 76 ms 2392 KB Output is correct
10 Correct 89 ms 2384 KB Output is correct