Submission #1100739

#TimeUsernameProblemLanguageResultExecution timeMemory
1100739RiverFlowTeams (IOI15_teams)C++14
0 / 100
4074 ms27980 KiB
#include <bits/stdc++.h> #define nl "\n" #define no "NO" #define yes "YES" #define fi first #define se second #define vec vector #define task "main" #define _mp make_pair #define ii pair<int, int> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define evoid(val) return void(std::cout << val) #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FOD(i, b, a) for(int i = (b); i >= (a); --i) #define unq(x) sort(all(x)); x.resize(unique(all(x)) - x.begin()) using namespace std; template<typename U, typename V> bool maxi(U &a, V b) { if (a < b) { a = b; return 1; } return 0; } template<typename U, typename V> bool mini(U &a, V b) { if (a > b) { a = b; return 1; } return 0; } const int N = (int)2e5 + 9; const int mod = (int)1e9 + 7; void prepare(); void main_code(); int n, m; int a[N], b[N], k[N]; vector<int> ins[N]; void init(int N, int A[], int B[]) { n = N; FOR(i, 0, n - 1) { a[i] = A[i], b[i] = B[i]; ins[a[i]].push_back(i); } } int can(int M, int K[]) { priority_queue<ii, vec<ii>, greater<ii>> pq; m = M; FOR(i, 0, m - 1) k[i] = K[i]; for(int i = 0, lst = -1; i < m; ++i) { int x = k[i]; while (lst + 1 <= x) { ++lst; for(int j : ins[lst]) { pq.push(_mp(b[j], j)); } } int t = x; while (t > 0) { if (sz(pq) == 0) { t = -1; break ; } while (sz(pq) and b[pq.top().se] < x) { pq.pop(); } if (sz(pq)) { pq.pop(); --t; } } if (t == -1) { return 0; } lst = x; } return 1; } #ifdef LOCAL int aa[N], bb[N], kk[N]; int main() { freopen("main.inp", "r", stdin); freopen("main.out", "w", stdout); int n; cin >> n; FOR(i, 0, n - 1) cin >> aa[i] >> bb[i]; init(n, aa, bb); int q; cin >> q; while (q--) { int m; cin >> m; FOR(i, 0, m - 1) cin >> kk[i]; cout << can(m, kk) << nl; } } #endif

Compilation message (stderr)

teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:39:15: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   39 | void init(int N, int A[], int B[]) {
      |           ~~~~^
teams.cpp:28:11: note: shadowed declaration is here
   28 | const int N = (int)2e5 + 9;
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...