제출 #304626

#제출 시각아이디문제언어결과실행 시간메모리
304626lolicon카니발 티켓 (IOI20_tickets)C++14
27 / 100
753 ms51704 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> ans; for (int i = 0; i < n; i++) { vector<int> row(m, -1); ans.push_back(row); } int Cnt = 0; vector<int> cnt(n); vector<pair<int, int>> v; for(int i = 0; i < n; i++) { int l = x[i][0]; int r = x[i][m - 1]; v.emplace_back(l, i); v.emplace_back(r, i); v.emplace_back((l + r) / 2, i); } int p; sort(all(v)); for(int i = 0; i < 3 * n; i++) { cnt[v[i].second]++; if(cnt[v[i].second] == 2) { Cnt++; } if(Cnt == n / 2) { p = i; break; } } for(int i = 0; i < 3 * n; i++) { if(cnt[v[i].second] >= 2) ans[v[i].second][0] = 0; else ans[v[i].second][m - 1] = 0; } // cal long long ret = 0; vector<vector<int>> T(k); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(ans[i][j] != -1) { T[ans[i][j]].push_back(x[i][j]); } } } for(int i = 0; i < k; i++) { sort(begin(T[i]), end(T[i])); int p = T[i][n / 2]; for(int j = 0; j < n; j++) { ret = ret + (long long)abs(p - T[i][j]); } } allocate_tickets(ans); /*for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cout << ans[i][j] << " \n"[j == m - 1]; } }*/ return ret; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:26:6: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   26 |  int p;
      |      ^
#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...