Submission #600245

# Submission time Handle Problem Language Result Execution time Memory
600245 2022-07-20T14:56:07 Z inventiontime Carnival Tickets (IOI20_tickets) C++17
27 / 100
530 ms 96292 KB
#include "tickets.h"

#include <bits/stdc++.h>
using namespace std;

#define int ll

#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define re resize
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define loop(i, n) for(int i = 0; i < n; i++)
#define loop1(i, n) for(int i = 1; i <= n; i++)
#define print(x) cout << #x << ": " << x << endl << flush

typedef long long ll;
typedef vector<int> vi;
typedef array<int, 2> ii;
typedef array<int, 3> ti;
typedef vector<ii> vii;
typedef vector<ti> vti;
typedef vector<vi> vvi;
typedef priority_queue<int> pq;

template<class T> bool ckmin(T&a, T b) { bool B = a > b; a = min(a, b); return B; }
template<class T> bool ckmax(T&a, T b) { bool B = a < b; a = max(a, b); return B; }

const int inf = 1e17;
const int maxn = 1505;

ii dp[maxn][maxn];

long long find_maximum(signed k, vector<vector<signed>> x) {

	int n = x.size();
	int m = x[0].size();

    if(false) {

        vi v;
        loop(i, n) v.pb(x[i][0]);

        sort(all(v));
        int res = 0;
        loop(i, n/2) res -= v[i];
        loop(i, n/2) res += v[n/2 + i];

        vector<vector<signed>> answer;
        vector<signed> row(1, 0);
        loop(i, n) answer.pb(row);

        allocate_tickets(answer);

        return res;

    } else if(k == 1) {
        vi high(1), low(1);
        loop(i, n) {
            high.pb(*max_element(all(x[i])));
            low.pb(*min_element(all(x[i])));
        }

        loop1(i, n) loop(j, i+1) { dp[i][j] = {-inf, 0}; }

        loop1(i, n) loop(j, i+1) {
            if(i-1 >= j) ckmax(dp[i][j], {dp[i-1][j][0] + high[i], 1});
            if(j > 0 and i-1 >= j-1) ckmax(dp[i][j], {dp[i-1][j-1][0] - low[i], -1});
        }

        vi taken(n+1);
        int j = n/2;
        for(int i = n; i >= 1; i--) {
            taken[i] = dp[i][j][1];
            if(taken[i] == -1) { j--; }
        }
        vector<vector<signed>> answer(n, vector<signed>(m, -1));
        loop1(i, n) {
            int idx = -1;
            if(taken[i] == -1) idx = min_element(all(x[i-1])) - x[i-1].begin();
            if(taken[i] == +1) idx = max_element(all(x[i-1])) - x[i-1].begin();
            answer[i-1][idx] = 0;
        }
        
        allocate_tickets(answer);

        return dp[n][n/2][0];

    }

	return 1;

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 684 KB Output is correct
5 Correct 2 ms 2232 KB Output is correct
6 Correct 29 ms 23884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 30 ms 5068 KB Output is correct
6 Correct 530 ms 96292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: failure to call allocate_tickets
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: failure to call allocate_tickets
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: failure to call allocate_tickets
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB WA in grader: failure to call allocate_tickets
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 684 KB Output is correct
5 Correct 2 ms 2232 KB Output is correct
6 Correct 29 ms 23884 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 852 KB Output is correct
11 Correct 30 ms 5068 KB Output is correct
12 Correct 530 ms 96292 KB Output is correct
13 Incorrect 0 ms 212 KB WA in grader: failure to call allocate_tickets
14 Halted 0 ms 0 KB -