제출 #303079

#제출 시각아이디문제언어결과실행 시간메모리
303079tutis카니발 티켓 (IOI20_tickets)C++17
100 / 100
1156 ms62500 KiB
#include "tickets.h" #include <vector> #include <bits/stdc++.h> using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); bool vien = true; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (x[i][j] < 0 || x[i][j] > 1) vien = false; vector<vector<int>> answer(n, vector<int>(m, -1)); int mxp = n / 2 * k; int P[n]; vector<pair<int, int>>A; for (int i = 0; i < n; i++) { P[i] = 0; for (int j = 0; j < k; j++) A.push_back({x[i][k - 1 - j] + x[i][m - 1 - j], i}); } sort(A.begin(), A.end(), greater<pair<int, int>>()); for (int i = 0; i < (int)A.size() / 2; i++) P[A[i].second]++; int a[n]; int b[n]; for (int i = 0; i < n; i++) { a[i] = 0; b[i] = m - 1; } long long ret = 0; for (int g = 0; g < k; g++) { pair<int, int>xx[n]; for (int i = 0; i < n; i++) xx[i] = {P[i], i}; sort(xx, xx + n); for (int i = 0; i < n / 2; i++) { int id = xx[i].second; ret -= x[id][a[id]]; answer[id][a[id]] = g; a[id]++; } for (int i = n / 2; i < n; i++) { int id = xx[i].second; ret += x[id][b[id]]; answer[id][b[id]] = g; b[id]--; P[id]--; } } allocate_tickets(answer); return ret; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:8:7: warning: variable 'vien' set but not used [-Wunused-but-set-variable]
    8 |  bool vien = true;
      |       ^~~~
tickets.cpp:14:6: warning: unused variable 'mxp' [-Wunused-variable]
   14 |  int mxp = n / 2 * k;
      |      ^~~
#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...