답안 #99551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99551 2019-03-05T04:30:21 Z DrumpfTheGodEmperor Exhibition (JOI19_ho_t2) C++14
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e5 + 5;
int n, m, c[N];
struct Picture { int s, v; } p[N];
bool cmp1(const Picture &lhs, const Picture &rhs) { return lhs.s < rhs.s; }
bool cmp2(const Picture &lhs, const Picture &rhs) { return lhs.v < rhs.v; }
bool check(int x) {
	if (!x) return 1;
	vector<Picture> v;
	fw (i, 0, x) v.pb(p[i]);
	sort(v.begin(), v.end(), cmp2);
	int ptr = 0;
	fw (i, 0, v.size()) {
		while (ptr < m && c[ptr] < v[i].s) ptr++;
		if (ptr == m) return 0;
		ptr++;
	}
	return 1;
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	fw (i, 0, n) cin >> p[i].s >> p[i].v;
	sort(p, p + n, cmp1);
	fw (i, 0, m) cin >> c[i];
	sort(c, c + m);
	int l = 0, r = n;
	while (l < r) {
		int m = (l + r) >> 1;
		if (check(m + 1)) l = m + 1;
		else r = m;
	}
	cout << l;
	return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'bool check(int)':
joi2019_ho_t2.cpp:10:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fw(i, l, r) for (int i = l; i < r; i++)
joi2019_ho_t2.cpp:26:6:
  fw (i, 0, v.size()) {
      ~~~~~~~~~~~~~~                    
joi2019_ho_t2.cpp:26:2: note: in expansion of macro 'fw'
  fw (i, 0, v.size()) {
  ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Incorrect 3 ms 384 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Incorrect 3 ms 384 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Incorrect 3 ms 384 KB Output isn't correct
14 Halted 0 ms 0 KB -