Submission #1061728

#TimeUsernameProblemLanguageResultExecution timeMemory
1061728anangoTeams (IOI15_teams)C++17
0 / 100
4070 ms24748 KiB
#include "teams.h" #include <bits/stdc++.h> #define int long long using namespace std; int n; vector<pair<int,int>> students; vector<int> ar; vector<int> br; void init(signed N, signed A[], signed B[]) { n=N; ar=br=vector<int>(n); students=vector<pair<int,int>>(n); for (int i=0; i<n; i++) { ar[i] = A[i]; br[i] = B[i]; students[i] = {A[i],B[i]}; } sort(students.begin(), students.end(), [&](const pair<int,int> &p1, const pair<int,int> &p2) { return p1.second<p2.second; }); } signed can(signed M, signed K[]) { int m = M; vector<int> kvals; for (int i=0; i<m; i++) { kvals.push_back(K[i]); } sort(kvals.begin(), kvals.end()); map<int,int> need; for (auto i:kvals) { need[i]+=i; } vector<vector<int>> req; for (auto i:need) { req.push_back({i.first,i.second}); } sort(req.begin(), req.end()); int pointer = 0; signed work = 0; for (auto student:students) { if (pointer==req.size()) { work=1; break; } if (student.first>req[pointer][0]) continue; if (student.second<req[pointer][0]) continue; //cout << "prereduced " << pointer <<" " << req[pointer][0] <<" " << req[pointer][1] << endl; req[pointer][1]--; //cout << "reduced " << pointer <<" " << req[pointer][0] <<" " << req[pointer][1] << endl; if (req[pointer][1]==0) { pointer++; } } if (pointer==req.size()) { work=1; } return work; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:41:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   if (pointer==req.size()) {
      |       ~~~~~~~^~~~~~~~~~~~
teams.cpp:55:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  if (pointer==req.size()) {
      |      ~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...