제출 #392345

#제출 시각아이디문제언어결과실행 시간메모리
392345EnkognitCarnival Tickets (IOI20_tickets)C++14
27 / 100
668 ms73340 KiB
#include <bits/stdc++.h>
#include "tickets.h"
#define ll long long
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()

using namespace std;

bool tt[100001];

long long find_maximum(int k, std::vector<std::vector<int>> a) {
	int n = a.size();
	int m = a[0].size();
	std::vector<std::vector<int>> answer;
	answer.resize(n);
	for (int i = 0; i < n; i++)
        answer[i].resize(m, -1);
	vector<pll> v;
	for (int i = 0; i < n; i++)
        v.pb(mp(0, m-1));
    ll ans=0;
    for (int it = 0; it < k; it++)
    {
        ll sm=0;
        vector<pll> z;
        for (int i = 0; i < n; i++) tt[i]=0;

        for (int i = 0; i < n; i++)
        {
            sm-=a[i][v[i].fi];
            z.pb(mp(a[i][v[i].se]+a[i][v[i].fi], i));
        }

        sort(all(z));

        for (int i = n/2; i < n; i++)
        {
            tt[z[i].se]=1;
            sm+=z[i].fi;
        }

        ans+=sm;

        for (int i = 0; i < n; i++)
            if (tt[i])
            {
                answer[i][v[i].se]=it;
                v[i].se--;
            }else
            {
                answer[i][v[i].fi]=it;
                v[i].fi++;
            }
    }
	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...