# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
725467 | 2023-04-17T13:35:47 Z | buffering | Exhibition (JOI19_ho_t2) | C++17 | 1000 ms | 5392 KB |
#include <bits/stdc++.h> using namespace std; void IO(string s = "") { if (s == "") { freopen("input.txt", "r", stdin); freopen("output 2.txt", "w", stdout); } if (s != "") { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } } bool check(int k, vector<pair<int, int>>& p, vector<int>& frames) { vector<int> sizes; for (int i = frames.size() - k; i < frames.size(); i++) { sizes.push_back(frames[i]); } bool works = true; int pointer = 0; for (int i = 0; i < k; i++) { bool curr = false; for (int j = pointer; j < p.size(); j++) { if (p[j].second <= sizes[i]) { pointer = j + 1; curr = true; break; } } works &= curr; if (pointer >= p.size() && i != k - 1) { works = false; break; } } return works; } int main() { ios::sync_with_stdio(false); cin.tie(0); //IO(); /* Binary search for answer If x is k, choose suffix of sizes for frames For each i in suffix, choose frame with size <= i with least value */ int n; int m; cin >> n >> m; vector<pair<int, int>> p(n); vector<int> frames(m); for (int i = 0; i < n; i++) { cin >> p[i].second >> p[i].first; //{value, size} } for (int i = 0; i < m; i++) { cin >> frames[i]; } sort(p.begin(), p.end()); sort(frames.begin(), frames.end()); int lo = 0; int hi = min(n, m); while (lo <= hi) { int mid = (lo + hi)/2; if (check(mid, p, frames)) { if (mid == min(n, m) || !check(mid + 1, p, frames)) { cout << mid << endl; return 0; } else lo = mid + 1; } else hi = mid - 1; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 320 KB | Output is correct |
3 | Correct | 1 ms | 320 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 316 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 320 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 320 KB | Output is correct |
3 | Correct | 1 ms | 320 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 316 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 320 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 328 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 2 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 2 ms | 328 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 320 KB | Output is correct |
3 | Correct | 1 ms | 320 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 316 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 320 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 328 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 2 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 2 ms | 328 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 1 ms | 332 KB | Output is correct |
38 | Correct | 64 ms | 5392 KB | Output is correct |
39 | Correct | 60 ms | 5288 KB | Output is correct |
40 | Correct | 64 ms | 5316 KB | Output is correct |
41 | Correct | 80 ms | 5300 KB | Output is correct |
42 | Execution timed out | 1056 ms | 4676 KB | Time limit exceeded |
43 | Halted | 0 ms | 0 KB | - |