# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
1067385 |
2024-08-20T16:11:59 Z |
juicy |
버스 (JOI14_bus) |
C++17 |
|
150 ms |
17288 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 1e5 + 5, M = 3e5 + 5, inf = 1e9;
int n, m, q;
int s[M], t[M], x[M], y[M], dp[M], best[N];
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m;
vector<array<int, 3>> events;
for (int i = 1; i <= m; ++i) {
cin >> s[i] >> t[i] >> x[i] >> y[i];
events.push_back({x[i], 1, i});
events.push_back({y[i], 0, i});
}
sort(events.begin(), events.end());
fill(best + 1, best + n + 1, -inf);
vector<array<int, 2>> cands;
for (auto [_, type, i] : events) {
if (!type) {
best[t[i]] = max(best[t[i]], dp[i]);
if (t[i] == n && dp[i] != -inf) {
cands.push_back({y[i], dp[i]});
}
} else {
if (s[i] == 1) {
dp[i] = x[i];
} else {
dp[i] = best[s[i]];
}
}
}
for (int i = 1; i < cands.size(); ++i) {
cands[i][1] = max(cands[i][1], cands[i - 1][1]);
}
auto qry = [&](int x) {
int it = lower_bound(cands.begin(), cands.end(), array<int, 2>{x, inf}) - cands.begin();
return it == 0 ? -1 : cands[it - 1][1];
};
cin >> q;
while (q--) {
int x; cin >> x;
cout << qry(x) << "\n";
}
return 0;
}
Compilation message
bus.cpp: In function 'int main()':
bus.cpp:43:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (int i = 1; i < cands.size(); ++i) {
| ~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
600 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
14 ms |
1240 KB |
Output is correct |
3 |
Correct |
14 ms |
1116 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
9 ms |
632 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
9 ms |
1176 KB |
Output is correct |
10 |
Correct |
16 ms |
2136 KB |
Output is correct |
11 |
Correct |
10 ms |
1296 KB |
Output is correct |
12 |
Correct |
18 ms |
2160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
128 ms |
16816 KB |
Output is correct |
2 |
Correct |
129 ms |
16824 KB |
Output is correct |
3 |
Correct |
129 ms |
16876 KB |
Output is correct |
4 |
Correct |
142 ms |
16900 KB |
Output is correct |
5 |
Correct |
130 ms |
17076 KB |
Output is correct |
6 |
Correct |
133 ms |
17072 KB |
Output is correct |
7 |
Correct |
127 ms |
17088 KB |
Output is correct |
8 |
Correct |
130 ms |
17232 KB |
Output is correct |
9 |
Correct |
128 ms |
17076 KB |
Output is correct |
10 |
Correct |
126 ms |
17076 KB |
Output is correct |
11 |
Correct |
123 ms |
17084 KB |
Output is correct |
12 |
Correct |
124 ms |
17180 KB |
Output is correct |
13 |
Correct |
130 ms |
17072 KB |
Output is correct |
14 |
Correct |
123 ms |
17220 KB |
Output is correct |
15 |
Correct |
124 ms |
17084 KB |
Output is correct |
16 |
Correct |
38 ms |
6332 KB |
Output is correct |
17 |
Correct |
38 ms |
5064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
139 ms |
17280 KB |
Output is correct |
2 |
Correct |
139 ms |
17068 KB |
Output is correct |
3 |
Correct |
140 ms |
17076 KB |
Output is correct |
4 |
Correct |
138 ms |
17212 KB |
Output is correct |
5 |
Correct |
143 ms |
17076 KB |
Output is correct |
6 |
Correct |
140 ms |
17168 KB |
Output is correct |
7 |
Correct |
141 ms |
17076 KB |
Output is correct |
8 |
Correct |
143 ms |
17112 KB |
Output is correct |
9 |
Correct |
150 ms |
17076 KB |
Output is correct |
10 |
Correct |
139 ms |
17168 KB |
Output is correct |
11 |
Correct |
138 ms |
17220 KB |
Output is correct |
12 |
Correct |
138 ms |
17080 KB |
Output is correct |
13 |
Correct |
137 ms |
17072 KB |
Output is correct |
14 |
Correct |
137 ms |
17288 KB |
Output is correct |
15 |
Correct |
148 ms |
17228 KB |
Output is correct |
16 |
Correct |
48 ms |
6592 KB |
Output is correct |