제출 #1007466

#제출 시각아이디문제언어결과실행 시간메모리
1007466u_suck_o카니발 티켓 (IOI20_tickets)C++17
11 / 100
1 ms5212 KiB
#include "tickets.h" #include "bits/stdc++.h" #define SZ 1505 using namespace std; bool large[SZ][SZ], small[SZ][SZ]; int cnt[SZ]; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> answer = vector<vector<int>>(n, vector<int>(m, -1)); vector<pair<int, pair<int, int>>> v; //{number, {ticket color, ticket id}} for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { v.push_back({x[i][j], {i, j}}); } } sort(v.begin(), v.end()); long long ans = 0; int count = 0; for (int i = v.size()-1; i >= 0; i--) { if (count == n/2 * k) break; if (cnt[v[i].second.first] < k) { ans += v[i].first; large[v[i].second.first][v[i].second.second] = true; cnt[v[i].second.first]++; count++; } } count = 0; for (int i = 0; i < v.size(); i++) { if (count == n/2 * k) break; if (cnt[v[i].second.first] < k && answer[v[i].second.first][v[i].second.second] == -1) { ans -= v[i].first; small[v[i].second.first][v[i].second.second] = true; cnt[v[i].second.first]++; count++; } } set<pair<int,int>> rounds; for (int i = 0; i < k; i++) rounds.insert({0, i}); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (small[i][j] || large[i][j]) { auto p = *rounds.begin(); answer[i][j] = p.second; rounds.erase(rounds.begin()); rounds.insert({p.first+1, p.second}); } } } allocate_tickets(answer); return ans; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
#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...