Submission #374663

#TimeUsernameProblemLanguageResultExecution timeMemory
374663idk321Teams (IOI15_teams)C++11
34 / 100
4051 ms27948 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int* k; int n; vector<array<int, 2>> v; void init(int N, int A[], int B[]) { n = N; v.resize(n); for (int i = 0; i< n; i++) { v[i][0] = A[i]; v[i][1] = B[i]; } sort(v.begin(), v.end()); } int can(int m, int K[]) { k = K; sort(k, k + m); vector<vector<int>> from(m); for (int i = 0; i < n; i++) { auto it = lower_bound(k, k + m, v[i][0]); if (it != k + m && v[i][1] >= *it) { from[it - k].push_back(v[i][1]); } } for (int i = 0; i < m; i++) { sort(from[i].begin(), from[i].end()); } multiset<int> cur; for (int i = 0; i < m; i++) { for (int j : from[i]) cur.insert(j); while (!cur.empty() && *cur.begin() < k[i]) { cur.erase(cur.begin()); } for (int j = 0; j < k[i]; j++) { if (cur.empty()) { return 0; } cur.erase(cur.begin()); } } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...