제출 #302476

#제출 시각아이디문제언어결과실행 시간메모리
302476arnold518카니발 티켓 (IOI20_tickets)C++14
100 / 100
1199 ms97876 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1500; int N, M, K; int A[MAXN+10][MAXN+10]; int P[MAXN+10], Q[MAXN+10]; int ans2[MAXN+10][MAXN+10]; ll ans; int L[MAXN+10], R[MAXN+10], chk[MAXN+10]; ll find_maximum(int _K, vector<vector<int>> _X) { N=_X.size(); M=_X[0].size(); K=_K; for(int i=1; i<=N; i++) for(int j=1; j<=M; j++) A[i][j]=_X[i-1][j-1]; for(int i=1; i<=N; i++) P[i]=0; vector<pll> V; for(int i=1; i<=N; i++) for(int j=1; j<=K; j++) V.push_back({A[i][j+M-K]+A[i][j], i}); sort(V.begin(), V.end()); for(int i=0; i<V.size()/2; i++) P[V[i].second]++; for(int i=V.size()/2; i<V.size(); i++) Q[V[i].second]++; //for(int i=1; i<=N; i++) printf("%d %d\n", P[i], Q[i]); /* { priority_queue<pii> PQ1; priority_queue<pii> PQ2; for(int i=1; i<=N; i++) if(P[i]>1) PQ1.push({A[i][P[i]], i}); for(int i=1; i<=N; i++) if(P[i]==0) PQ2.push({-A[i][1], i}); while(PQ2.size()>N/2) { pii now=PQ1.top(); PQ1.pop(); pii now2=PQ2.top(); PQ2.pop(); P[now.second]--; P[now2.second]++; if(P[now.second]>1) PQ1.push({A[now.second][P[now.second]], now.second}); } } { priority_queue<pii> PQ1; priority_queue<pii> PQ2; for(int i=1; i<=N; i++) if(Q[i]>1) PQ1.push({-A[i][M-Q[i]+1], i}); for(int i=1; i<=N; i++) if(Q[i]==0) PQ2.push({A[i][M], i}); while(PQ2.size()>N/2) { pii now=PQ1.top(); PQ1.pop(); pii now2=PQ2.top(); PQ2.pop(); Q[now.second]--; Q[now2.second]++; if(Q[now.second]>1) PQ1.push({A[now.second][M-Q[now.second]+1], now.second}); } } for(int i=1; i<=N; i++) { for(int j=1; j<=P[i]; j++) ans-=A[i][j]; for(int j=1; j<=Q[i]; j++) ans+=A[i][M-j+1]; printf("PQ %d %d\n", P[i], Q[i]); } */ for(int i=1; i<=N; i++) L[i]=1, R[i]=1; for(int i=1; i<=K; i++) { vector<pii> V; for(int j=1; j<=N; j++) V.push_back({Q[j]-R[j]-P[j]+L[j], j}); sort(V.begin(), V.end()); for(int j=1; j<=N; j++) chk[j]=0; for(int j=0; j<N/2; j++) chk[V[j].second]=1; //printf("%lld %lld %lld %lld\n", L[i], R[j], P[j], Q[j]); for(int j=1; j<=N; j++) { if(!chk[j]) { ans+=A[j][M-R[j]+1]; ans2[j][M-R[j]+1]=i; R[j]++; } else { ans-=A[j][L[j]]; ans2[j][L[j]]=i; L[j]++; } } } vector<vector<int>> answer; answer=vector<vector<int>>(N, vector<int>(M)); for(int i=1; i<=N; i++) for(int j=1; j<=M; j++) answer[i-1][j-1]=ans2[i][j]-1; allocate_tickets(answer); return ans; }

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

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for(int i=0; i<V.size()/2; i++) P[V[i].second]++;
      |               ~^~~~~~~~~~~
tickets.cpp:31:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i=V.size()/2; i<V.size(); i++) Q[V[i].second]++;
      |                        ~^~~~~~~~~
#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...