제출 #831413

#제출 시각아이디문제언어결과실행 시간메모리
831413waldi팀들 (IOI15_teams)C++17
34 / 100
4080 ms45396 KiB
#include<bits/stdc++.h> #define FOR(i,p,k) for(int i=(p);i<=(k);++i) #define REP(i,n) FOR(i,0,(n)-1) using namespace std; int n; vector<vector<int>> kub; void init(int nn, int a[], int b[]){ n = nn; kub.resize(n+1); REP(i, n) kub[a[i]].emplace_back(b[i]); } int can(int m, int k[]){ vector<int> wym(n+1, 0); REP(i, m) wym[k[i]] += k[i]; // wym ma 2sqrt(n) niezerowych wartosci multiset<int> s; FOR(i, 1, n){ for(int x : kub[i]) s.emplace(x); while(s.size() && *s.begin() < i) s.erase(s.begin()); for(; wym[i]; --wym[i]){ if(s.empty()) return 0; s.erase(s.begin()); } } return 1; } #ifdef LOCAL #define maxn 1000 int main(){ int nn, a[maxn], b[maxn]; scanf("%d", &nn); REP(i, nn) scanf("%d%d", &a[i], &b[i]); init(nn, a, b); int q; scanf("%d", &q); while(q--){ int m, k[maxn]; scanf("%d", &m); REP(i, m) scanf("%d", &k[i]); int wyn = can(m, k); printf("%d\n", wyn); } } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...