Submission #163586

#TimeUsernameProblemLanguageResultExecution timeMemory
163586shenxyTeams (IOI15_teams)C++11
34 / 100
4024 ms16760 KiB
#include "teams.h" #include <algorithm> #include <queue> using namespace std; typedef pair<int, int> ii; int n; ii res[100000]; void init(int N, int A[], int B[]) { n = N; for (int i = 0; i < N; ++i) res[i] = ii(A[i], B[i]); sort(res, res + N); } int can(int M, int K[]) { priority_queue<int> pq; sort(K, K + M); int ptr = 0; for (int i = 0; i < M; ++i) { while (ptr != n && res[ptr].first <= K[i]) pq.push(-res[ptr++].second); while (!pq.empty() && -pq.top() < K[i]) pq.pop(); if (pq.size() < K[i]) return 0; 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:20:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (pq.size() < K[i]) 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...