제출 #1078886

#제출 시각아이디문제언어결과실행 시간메모리
1078886Jawad_Akbar_JJ카니발 티켓 (IOI20_tickets)C++17
11 / 100
3043 ms604 KiB
#include <iostream> #include <vector> #include <set> #include <algorithm> #include "tickets.h" using namespace std; #define f first #define s second long long find_maximum(int k, vector<vector<int>> x){ int n = x.size(); int m = x[0].size(); if (m == 1){ vector<int> vec; for (int i=0;i<n;i++) vec.push_back(x[i][0]), x[i][0] = 0; sort(begin(vec), end(vec)); long long ans = 0; for (int i=0;i<n;i++) ans += abs(vec[n / 2] - vec[i]); allocate_tickets(x); return ans; } vector<pair<pair<int,int>,int>> vec; for (int i=0;i<n;i++){ vec.push_back({{x[i][0], x[i][m-1]}, i}); for (int j=0;j<m;j++) x[i][j] = -1; } sort(begin(vec), end(vec)); multiset<pair<int,int>> ms; int h = n / 2; long long Mx = -1, ans = 0, ind = h - 1; for (int i=h-1;i<=n;i++){ bool fl = false; if (i == n){ i = ind; x[i][0] = 0; fl = true; } int b = vec[i].f.f; ans = 0; ms.clear(); for (int j=0;j<i;j++){ ans += b - vec[j].f.f; if (vec[j].f.s >= b) ms.insert({vec[j].f.s - b - b + vec[j].f.f, j}); if (fl) x[j][0] = 0; } int rem = h; for (int j=h+1;j<n;j++){ ans += vec[j].f.s - b; if (fl) x[j][m-1] = 0; rem--; } if (rem > ms.size()) continue; while (rem--){ auto [a, b] = *rbegin(ms); ans += a; if (fl){ x[b][0] = -1; x[b][m-1] = 0; } ms.erase(prev(end(ms))); } if (fl) break; if (ans > Mx) Mx = ans, ind = i; } allocate_tickets(x); return Mx; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:67:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::multiset<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |   if (rem > ms.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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...