Submission #540858

#TimeUsernameProblemLanguageResultExecution timeMemory
540858GioChkhaidzeTeams (IOI15_teams)C++14
0 / 100
4091 ms52704 KiB
#include <bits/stdc++.h> #include "teams.h" #define pb push_back using namespace std; const int Nn = 5e5 + 5; int n, a[Nn], b[Nn], f[Nn]; vector < int > G[Nn]; void init(int N, int A[], int B[]) { n = N; for (int i = 0; i < n; ++i) { a[i] = A[i], b[i] = B[i]; } for (int i = 0; i < n; ++i) { G[a[i]].pb(i); } } int can(int M, int K[]) { long long s = 0; for (int i = 0; i < M; ++i) { f[K[i]]++; s += K[i]; } multiset < int > st; bool ok = true; if (s > n) ok = false; else { for (int i = 1; i <= n; ++i) { for (int j = 0; j < G[i].size(); ++j) { int id = G[i][j]; st.insert(b[id]); } for (int j = 1; j <= 1ll * f[i] * i; ++j) { if (!st.size()) { ok = false; break; } if ((*st.begin()) < i) { ok = false; break; } st.erase(st.find(*st.begin())); } if(!ok) break; } } for (int i = 0; i < M; ++i) { f[K[i]] = 0; } return ok; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |    for (int j = 0; j < G[i].size(); ++j) {
      |                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...