제출 #601294

#제출 시각아이디문제언어결과실행 시간메모리
601294definitelynotmee카니발 티켓 (IOI20_tickets)C++17
100 / 100
1169 ms187508 KiB
#include "tickets.h" #include <vector> #include<bits/stdc++.h> #define mp make_pair #define mt make_tuple #define all(x) x.begin(), x.end() #define ff first #define ss second using namespace std; template <typename T> using matrix = vector<vector<T>>; typedef unsigned int uint; typedef unsigned long long ull; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INFL = (1LL<<62)-1; const int INF = (1<<30)-1; const double EPS = 1e-7; const int MOD = 1e9 + 7; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); const int MAXN = 1e6+1; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); matrix<int> group(n,vector<int>(m,-1)); ll resp = 0; vector<int> minuscount(n,k); priority_queue<pii> pq; for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ resp-=x[i][j]; pq.push({x[i][j]+x[i][m+j-k],i}); } } for(int i = 0; i < n*k/2; i++){ pii cur = pq.top(); pq.pop(); resp+=cur.ff; minuscount[cur.ss]--; } vector<pii> minus, plus; minus.reserve(n*k/2); plus.reserve(n*k/2); for(int i = 0; i < n; i++){ for(int j = 0; j < minuscount[i]; j++){ minus.push_back({i,j}); } for(int j = m-1; j >= m-(k-minuscount[i]); j--){ plus.push_back({i,j}); } } vector<set<int>> occupy(k); vector<int> curid(n); int id = 0; for(pii i : plus){ occupy[id].insert(i.ff); group[i.ff][i.ss] = id; id = (id+1)%k; } for(pii i : minus){ while(!(occupy[curid[i.ff]].size() < n && !occupy[curid[i.ff]].count(i.ff))){ curid[i.ff]++; //assert(curid[i.ff] < k); } occupy[curid[i.ff]].insert(i.ff); group[i.ff][i.ss] = curid[i.ff]; curid[i.ff]++; } allocate_tickets(group); return resp; }

컴파일 시 표준 에러 (stderr) 메시지

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:73:44: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |         while(!(occupy[curid[i.ff]].size() < n && !occupy[curid[i.ff]].count(i.ff))){
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...