Submission #285803

#TimeUsernameProblemLanguageResultExecution timeMemory
285803DystoriaXTeams (IOI15_teams)C++14
34 / 100
4097 ms25976 KiB
#include "teams.h" #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <bitset> // #include <numeric> using namespace std; int n; vector<int> st[100010], en[100010]; int pt[100010]; bitset<100010> act; vector<int> a, b; void init(int N, int A[], int B[]) { n = N; a.resize(1), b.resize(1); a.insert(a.end(), A, A + n); b.insert(b.end(), B, B + n); for(int i = 0; i < n; i++) st[A[i]].emplace_back(i + 1), en[B[i]].emplace_back(i + 1); } int can(int M, int K[]) { long long sum = 0; for(int i = 0; i < M; i++) sum += K[i]; if(sum > n) return 0; for(int i = 1; i <= n; i++) pt[i] = 0, act[i] = 0; for(int i = 0; i < M; i++) pt[K[i]] += K[i]; priority_queue<pair<int, int> > pq; for(int i = 1; i <= n; i++){ for(auto &k : st[i]) pq.push({-b[k], k}), act[k] = true; while(pt[i] && !pq.empty()){ int x = pq.top().second; pq.pop(); if(!act[x]) continue; act[x] = false; pt[i]--; } if(pt[i] && pq.empty()) return 0; for(auto &k : en[i]) act[k] = false; } 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...