This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long n, pos, sum;
vector<pair<int, int> > sz;
priority_queue<int> q;
vector<int> kerd;
//bool can(int m, vector<int> a) {
bool can(int m, int a[]) {
pos=0, sum=0;
for (int i=0; i<m; i++) sum+=a[i];
if (sum>n) return 0;
kerd.clear();
for (int i=0; i<m; i++) for (int j=0; j<a[i]; j++) kerd.push_back(a[i]);
sort(kerd.begin(), kerd.end());
for (int i=0; i<sum; i++) {
while(pos<n && sz[pos].first<=kerd[i]) q.push(sz[pos].second), pos++;
while(q.size() && kerd[i]>-q.top()) {
//cout << kerd[i] << " " << q.top() << endl;
q.pop();
}
if (q.size()==0) return 0;
q.pop();
}
while(q.size()) q.pop();
return 1;
}
//void init(int p, vector<int> a, vector<int> b) {
void init(int p, int a[], int b[]) {
n=p;
for (int i=0; i<n; i++) sz.push_back({a[i], -b[i]});
sort(sz.begin(), sz.end());
}
# | 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... |