제출 #343997

#제출 시각아이디문제언어결과실행 시간메모리
343997couplefire팀들 (IOI15_teams)C++17
34 / 100
4094 ms29804 KiB
#include <bits/stdc++.h> #include "teams.h" using namespace std; int n; vector<int> smol, big; int m; vector<int> groups; vector<vector<int>> tmp; map<int, int> mp; void init(int N, int* A, int* B){ n = N; smol = vector<int>(n), big = vector<int>(n); for(int i = 0; i<n; i++) smol[i] = A[i], big[i] = B[i]; tmp = vector<vector<int>>(n+1); for(int i = 0; i<n; i++) tmp[big[i]].push_back(smol[i]); for(int i = 1; i<=n; i++) sort(tmp[i].begin(), tmp[i].end()); } int can(int M, int* K){ m = M; groups = vector<int>(m); for(int i = 0; i<m; i++) groups[i] = K[i]; mp.clear(); for(int i = 0; i<m; i++) mp[groups[i]] += groups[i]; for(int i = 1; i<=n; i++){ for(auto x : tmp[i]){ if(mp.empty()) return 1; auto it = mp.lower_bound(x); if(it == mp.end()) break; int num = (*it).first; if(num > i) break; mp[num]--; if(mp[num] == 0) mp.erase(num); } } if(mp.empty()) return 1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...