# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
756591 | minhcool | Teams (IOI15_teams) | C++17 | 4046 ms | 13112 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#define local
#ifndef local
#include "teams.h"
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
mt19937 rng(1);
int rnd(int l, int r){
int temp = rng() % (r - l + 1);
return abs(temp) + l;
}
int n;
ii range[N];
void init(int N, int A[], int B[]){
n = N;
for(int i = 1; i <= n; i++) range[i] = {A[i - 1], B[i - 1]};
sort(range + 1, range + n + 1);
}
int can(int m, int k[]){
sort(k, k + m);
int itr = 1;
priority_queue<int, vector<int>, greater<int>> pq;
for(int i = 0; i < m; i++){
while(itr <= n && range[itr].fi <= k[i]){
pq.push(range[itr].se);
itr++;
}
//cout << i << " " << itr << "\n";
for(int j = 0; j < k[i]; j++){
if(pq.empty()) return 0;
// cout << pq.top().fi << "\n";
if(pq.top() < k[i]) return 0;
pq.pop();
}
}
//if(itr <= n || !pq.empty()) return 0;
return 1;
}
//#define local
#ifdef local
void process(){
int n;
cin >> n;
int a[n], b[n];
for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
init(n, a, b);
int q;
cin >> q;
while(q--){
int m;
cin >> m;
int k[m];
for(int i = 0; i < m; i++) cin >> k[i];
cout << can(m, k) << "\n";
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) process();
}
#endif
Compilation message (stderr)
# | 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... |