Submission #814278

# Submission time Handle Problem Language Result Execution time Memory
814278 2023-08-08T06:40:01 Z 이동현(#10122) Arranging Tickets (JOI17_arranging_tickets) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int L, n;
    cin >> L >> n;
    vector<array<int, 4>> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
        --a[i][0], --a[i][1];

        assert(a[i][2] == 1);

        if(a[i][0] > a[i][1]) swap(a[i][0], a[i][1]);
    }

    int ans = (int)1e9;
    auto sol = [&](){
        vector<int> pre(L);
        for(int i = 0; i < n; ++i){
            if(!a[i][3]){
                pre[a[i][0]] += 1;
                pre[a[i][1]] -= 1;
            }
            else{
                pre[a[i][1]] += 1;
                pre[0] += 1;
                pre[a[i][0]] -= 1;
            }
        }

        int nans = 0;
        for(int i = 0; i < L; ++i){
            if(i) pre[i] += pre[i - 1];

            nans = max(nans, pre[i]);
        }

        ans = min(ans, nans);
    };

    assert(n <= 300);
    sort(a.begin(), a.end(), [&](array<int, 4>&x, array<int, 4>&y){return x[1] - x[0] > y[1] - y[0];});

    for(int i = 0; i < n; ++i){
        for(int j = i - 1; j < n; ++j){
            for(int k = 0; k < n; ++k){
                a[k][3] = (i <= k && k <= j);
            }

            sol();
        }
    }

    cout << ans << '\n';
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -