Submission #922765

# Submission time Handle Problem Language Result Execution time Memory
922765 2024-02-06T06:09:13 Z Alihan_8 Carnival Tickets (IOI20_tickets) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

//#include "tickets.h"

#include "ac.h"

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
//#define int long long

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
}

long long find_maximum(int k, std::vector<std::vector<int>> a) {

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

	vector <int> L(n), R(n, m - 1);

	vector <vector<int>> ret(n, vector <int> (m, -1));

	for ( int t = 0; t < k; t++ ){

        vector <ar<int,2>> p;

        for ( int j = 0; j < n; j++ ){
            p.pb({a[j][L[j]] + a[j][R[j]], j});
        }

        sort(all(p));

        for ( int i = 0; i < n; i++ ){
            int j = p[i][1];
            if ( i < n / 2 ){
                ret[j][L[j]] = t;
                L[j]++;
            } else{
                ret[j][R[j]] = t;
                R[j]--;
            }
        }
	}

	allocate_tickets(ret);

	auto f = [&](auto a){
        sort(all(a));
        int s = a.size();
        i64 cnt = 0;
        for ( auto &x: a ){
            cnt += abs(a[s / 2] - x);
        }
        return cnt;
	};

    vector <vector<int>> q(k);

    for ( int i = 0; i < n; i++ ){
        for ( int j = 0; j < m; j++ ){
            if ( ret[i][j] != -1 ){
                q[ret[i][j]].pb(a[i][j]);
            }
        }
    }

    i64 ans = 0;
    for ( auto &x: q ){
        ans += f(x);
    }
    return ans;
}

Compilation message

tickets.cpp:5:10: fatal error: ac.h: No such file or directory
    5 | #include "ac.h"
      |          ^~~~~~
compilation terminated.