Submission #288968

#TimeUsernameProblemLanguageResultExecution timeMemory
288968BertedTeams (IOI15_teams)C++14
21 / 100
35 ms8320 KiB
#include "teams.h" #include <iostream> #include <utility> #include <algorithm> #include <vector> #include <bitset> #include <queue> #define pii pair<int, int> #define fst first #define snd second const int SZ = (1 << 20) + 5, SZ2 = 500005; using namespace std; struct p_node { int v = 0, l = -1, r = -1; p_node() {} }; int n; pii a[105]; priority_queue<pii, vector<int>, greater<int>> pq; void init(int N, int A[], int B[]) { n = N; for (int i = 0; i < N; i++) {a[i] = {A[i], B[i]};} sort(a, a + N); } int can(int M, int K[]) { sort(K, K + M); while (pq.size()) {pq.pop();} int j = 0; for (int i = 0; i < M; i++) { for (; j < n && a[j].fst <= K[i]; j++) {pq.push(a[j].snd);} while (pq.size() && pq.top() < K[i]) {pq.pop();} if (pq.size() < K[i]) {return 0;} else {for (int j = 0; j < K[i]; j++) {pq.pop();}} } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:41:17: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<int, int>, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |   if (pq.size() < K[i]) {return 0;}
      |       ~~~~~~~~~~^~~~~~
teams.cpp:42:18: warning: declaration of 'j' shadows a previous local [-Wshadow]
   42 |   else {for (int j = 0; j < K[i]; j++) {pq.pop();}}
      |                  ^
teams.cpp:36:6: note: shadowed declaration is here
   36 |  int j = 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...