제출 #471277

#제출 시각아이디문제언어결과실행 시간메모리
471277Cross_Ratio카니발 티켓 (IOI20_tickets)C++14
41 / 100
692 ms57820 KiB
#include <bits/stdc++.h> //#include "tickets.h" using namespace std; void allocate_tickets(vector<vector<int>>); typedef pair<int,int> P; long long find_maximum(int k, vector<vector<int> > x) { int N = x.size(); int M = x[0].size(); vector<vector<int> > ans; ans.resize(N); int i,j; for(i=0;i<N;i++) { ans[i].resize(M); fill(ans[i].begin(),ans[i].end(),-1); } long long int cnt = 0; if(k==1) { vector<int> pt1; vector<int> pt2; pt1.resize(N); pt2.resize(N); fill(pt2.begin(),pt2.end(),M-1); int j, st; for(j=0;j<k;j++) { vector<P> V; for(i=0;i<N;i++) { V.push_back(P(x[i][pt2[i]]+x[i][pt1[i]],i)); } sort(V.begin(),V.end()); for(i=0;i<N;i++) { int n = V[i].second; if(i < N / 2) { ans[n][pt1[n]] = j; cnt -= x[n][pt1[n]]; pt1[n]++; } else { ans[n][pt2[n]] = j; cnt += x[n][pt2[n]]; pt2[n]--; } } } allocate_tickets(ans); return cnt; } else { vector<P> A; A.resize(N); for(i=0;i<N;i++) { for(j=0;j<M;j++) { A[i].first += x[i][j]; } A[i].second = i; } vector<int> pt1; vector<int> pt2; pt1.resize(N); pt2.resize(N); fill(pt2.begin(),pt2.end(),M-1); sort(A.begin(),A.end(),[](P x, P y) {return x.first > y.first;}); for(i=0;i<k;i++) { for(j=0;j<N;j++) { if(j < N/2) { ans[A[j].second][pt2[A[j].second]] = i; cnt += x[A[j].second][pt2[A[j].second]]; A[j].first -= x[A[j].second][pt2[A[j].second]]; pt2[A[j].second]--; } else { ans[A[j].second][pt1[A[j].second]] = i; cnt -= x[A[j].second][pt1[A[j].second]]; A[j].first -= x[A[j].second][pt1[A[j].second]]; pt1[A[j].second]++; } } sort(A.begin(),A.end(),[](P x, P y) {return x.first > y.first;}); } allocate_tickets(ans); return cnt; } }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:26:16: warning: unused variable 'st' [-Wunused-variable]
   26 |         int j, st;
      |                ^~
#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...