Submission #432104

# Submission time Handle Problem Language Result Execution time Memory
432104 2021-06-17T20:57:16 Z Enkognit Carnival Tickets (IOI20_tickets) C++14
0 / 100
8 ms 9932 KB
#include <bits/stdc++.h>
#include "tickets.h"
#define ll long long
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first
#define se second
#define all(v) v.begin(),v.end()

using namespace std;

ll qq[100005];
vector<vector<pll> > a;
vector<ll> mn[100005], mx[100005];

long long find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	std::vector<std::vector<int> > answer;
	set<pll> s;
	for (int i = 0; i < n; i++)
    {
        vector<pll> vv;
        for (int j = 0; j < m; j++)
            vv.pb(mp(x[i][j], j));
        qq[i]=k;
        sort(all(vv));
        a.pb(vv);
        s.insert(mp(a[i].back().fi+a[i][qq[i]-1].fi, i));
    }


    for (int i = 0; i < k*n/2; i++)
    {
        pll x=*s.begin();
        s.erase(s.begin());
        qq[x.se]--;
        if (qq[x.se]>0)
            s.insert(mp(a[x.se][a[x.se].size()-(k-qq[x.se])].fi+a[x.se][qq[x.se]].fi, x.se));
    }
    answer.resize(n);
    for (int i = 0; i < n; i++)
    {
        answer[i].resize(m, -1);
        for (int j = 0; j < a[i].size(); j++)
            if (j<qq[i]) mn[i].pb(a[i][j].se); else
            if (j>=a[i].size()-(k-qq[i])) mx[i].pb(a[i][j].se);
        reverse(all(mn[i]));
    }

    for (int i = 0; i < k; i++)
    {
        vector<pll> vv;
        for (int j = 0; j < n; j++)
            vv.pb(mp(-mx[i].size(), i));
        sort(all(vv));
        for (int j = 0; j < n/2; j++)
        {
            answer[vv[j].se][mx[vv[j].se].back()]=i;
            mx[vv[j].se].pop_back();
        }
        for (int j = n/2; j < n; j++)
        {
            answer[vv[j].se][mn[vv[j].se].back()]=i;
            mn[vv[j].se].pop_back();
        }
    }

	allocate_tickets(answer);
	return 1;
}

Compilation message

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:47:27: 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]
   47 |         for (int j = 0; j < a[i].size(); j++)
      |                         ~~^~~~~~~~~~~~~
tickets.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   49 |             if (j>=a[i].size()-(k-qq[i])) mx[i].pb(a[i][j].se);
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 9932 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 9848 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 9824 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 9932 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 9832 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 9832 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 9932 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -