이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "teams.h"
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 2e5 + 10;
int n, q, a[N], b[N];
void init(int _n, int A[], int B[]) {
n = _n;
for (int i = 0; i < n; ++i) a[i] = A[i], b[i] = B[i];
}
int can(int m, int x[]) {
vector <tuple <int, int, int>> events;
set <pair <int, int>> s;
for (int i = 0; i < m; ++i)
events.push_back({x[i], 0, i});
for (int i = 0; i < n; ++i) {
events.push_back({a[i], -1, i});
events.push_back({b[i], 1, i});
}
sort(events.begin(), events.end());
for (auto [x, sign, i]: events) {
if (sign == 0) {
int cur = 0;
while (cur < x) {
if (s.empty()) {
return 0;
}
s.erase(s.begin());
++cur;
}
} else if (sign == -1) s.insert({b[i], i});
else s.erase({b[i], i});
}
return 1;
}
//
//int main() {
// ios :: sync_with_stdio(0); cin.tie(0);
// cin >> n;
// int A[n], B[n];
// for (int i = 0; i < n; ++i) cin >> A[i] >> B[i];
// cin >> q;
// init(n, A, B);
// while (q--) {
// int m;
// cin >> m;
// int K[m];
// for (int i = 0; i < m; ++i) cin >> K[i];
// cout << can(m, K) << '\n';
// }
//}
컴파일 시 표준 에러 (stderr) 메시지
teams.cpp: In function 'int can(int, int*)':
teams.cpp:33:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
33 | for (auto [x, sign, i]: events) {
| ^
teams.cpp:33:16: warning: declaration of 'auto x' shadows a parameter [-Wshadow]
33 | for (auto [x, sign, i]: events) {
| ^
teams.cpp:23:20: note: shadowed declaration is here
23 | int can(int m, int x[]) {
| ~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |