Submission #1062786

# Submission time Handle Problem Language Result Execution time Memory
1062786 2024-08-17T10:48:53 Z jerzyk Carnival Tickets (IOI20_tickets) C++17
27 / 100
355 ms 72804 KB
#include <bits/stdc++.h>
#include "tickets.h"

using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const int II = 2 * 1000 * 1000 * 1000;
const ll M = 1000LL * 1000LL * 1000LL + 7LL;
const int N = 1500 + 7;
vector<pair<int, pair<int, int>>> kol;
vector<vector<int>> gam;
vector<int> lft[N][2];
int il[N];

bool Cp(int a, int b)
{
    int x = max(lft[a][0].size(), lft[a][1].size());
    int y = max(lft[b][0].size(), lft[b][1].size());
    return (x > y);
}

void DoAns(int n, int m, int k)
{
    vector<int> ord;
    for(int i = 0; i < n; ++i)
    {
        ord.pb(i);
        for(int j = 0; j < k - il[i]; ++j)
            lft[i][0].pb(j);
        for(int j = m - il[i]; j < m; ++j)
            lft[i][1].pb(j);
    }
    sort(ord.begin(), ord.end(), Cp);
    for(int l = 0; l < k; ++l)
    {
        int ilu = 0, ild = 0;
        for(int i = 0; i < n; ++i)
        {
            int v = ord[i];
            if(lft[v][0].size() > lft[v][1].size() || (lft[v][0].size() == lft[v][1].size() && ilu < ild))
            {
                ++ilu;
                gam[v][lft[v][0].back()] = l;
                lft[v][0].pop_back();
            }else
            {
                ++ild;
                gam[v][lft[v][1].back()] = l;
                lft[v][1].pop_back();
            }
        }
    }
}

ll find_maximum(int k, vector<vector<int>> x)
{
    int n = x.size(), m = x[0].size();
    gam = x;
    ll answer = 0LL;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < m; ++j)
            gam[i][j] = -1;

        for(int j = 0; j < k; ++j)
            answer -= x[i][j];
        for(int j = 0; j < k; ++j)
            kol.pb(make_pair(x[i][k - j - 1] + x[i][m - j - 1], make_pair(i, j + 1)));
    }
    sort(kol.begin(), kol.end());
    reverse(kol.begin(), kol.end());
    //cerr << answer << "\n";
    for(int i = 0; i < (n * k) / 2; ++i)
    {
        il[kol[i].nd.st] = kol[i].nd.nd;
        answer += (ll)kol[i].st;
        //cerr << i << " " << answer << " " << kol[i].st << "\n";
    }
    DoAns(n, m, k);
    allocate_tickets(gam);
    return answer;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 2 ms 900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 508 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 15 ms 3420 KB Output is correct
6 Correct 355 ms 72804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant returned 4 but the tickets gives a total value of 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant returned 11 but the tickets gives a total value of 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Contestant returned 11 but the tickets gives a total value of 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Contestant returned 11 but the tickets gives a total value of 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 2 ms 900 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 508 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 15 ms 3420 KB Output is correct
12 Correct 355 ms 72804 KB Output is correct
13 Incorrect 0 ms 348 KB Contestant returned 4 but the tickets gives a total value of 6
14 Halted 0 ms 0 KB -