Submission #302261

#TimeUsernameProblemLanguageResultExecution timeMemory
302261arnold518Carnival Tickets (IOI20_tickets)C++14
11 / 100
7 ms12800 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]; 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++) for(int j=1; j<=M; j++) if(A[i][j]==1) P[i]++; for(int i=1; i<=N; i++) r[i]=M, l[i]=1; for(int i=1; i<=K; i++) { vector<pii> V; for(int j=1; j<=N; j++) V.push_back({A[j][r[j]], j}); sort(V.begin(), V.end(), greater<pii>()); for(int j=1; j<=N; j++) chk[j]=0; for(int j=0; j<N/2; j++) chk[V[j].second]=1; for(int j=1; j<=N; j++) { if(chk[j]) { ans+=A[j][r[j]]; ans2[j][r[j]]=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; }
#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...