Submission #302711

#TimeUsernameProblemLanguageResultExecution timeMemory
302711DovranCarnival Tickets (IOI20_tickets)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> #include "tickets.h" #define N 2009 #define pii pair <int, int> #define ff first #define sz() size() #define ss second #define pb push_back #define ll long long using namespace std; int n, m, ans; pii c[N]; vector<pii> p; vector<vector<int>>s; int k; ll find_maximum(int g, vector<vector<int>>v){ k=g; n=v.sz(); s.resize(n); for(int i=0; i<n; i++) s[i].resize(m); m=v[0].sz(); for(int i=0; i<n ;i++) c[i]={0, m-1}; while(k){ p.empty(); for(int i=0; i<n; i++) p.pb({v[i][c[i].ff]+v[i][c[i].ss], i}); sort(p.begin(), p.end()); int x=0, y=0; for(int i=0; i<n; i++){ int in=p[i].ss; if(i<n/2) x+=v[in][c[in].ff], s[in][c[in].ff]=k, c[in].ff++; else y+=v[in][c[in].ss], s[in][c[in].ss]=k, c[in].ss++; } ans+=y-x; k--; } for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ if(s[i][j]==0) s[i][j]=-1; else s[i][j]=g-s[i][j]; } } allocate_tickets(s); return ans; } /* int main(){ int k; vector<vector<int>>v; int x, y, z; cin>>x>>y>>k; v.resize(x); for(int i=0; i<x; i++) for(int j=0; j<y; j++) cin>>z, v[i].pb(z); cout<<find_maximum(k, v); }*/
#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...