Submission #1077161

# Submission time Handle Problem Language Result Execution time Memory
1077161 2024-08-27T02:01:43 Z kwongweng Arranging Tickets (JOI17_arranging_tickets) C++17
10 / 100
128 ms 436 KB
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> ii;
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define ROF(i,a,b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second

int main(){
    ios::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);
    int n,m; cin>>n>>m;
    vi a(m), b(m), c(m); FOR(i,0,m) cin>>a[i]>>b[i]>>c[i];
    FOR(i,0,m){
        if (a[i]>b[i]) swap(a[i],b[i]);
    }
    vector<ll> cnt;
    ll mn = m;
    FOR(i,0,(1<<m)){
        cnt.assign(n+1,0);
        FOR(j,0,m){
            if (i&(1<<j)){
                cnt[a[j]+1]++; if (b[j]<n) cnt[b[j]+1]--;
            }else{
                cnt[1]++; cnt[a[j]+1]--; if (b[j]<n) cnt[b[j]+1]++;
            }
        }
        FOR(j,1,n+1) cnt[j] += cnt[j-1];
        ll mx = 0; FOR(j,1,n+1) mx = max(mx, cnt[j]);
        //cout<<" "; FOR(j,1,n+1) cout<<cnt[j]<<" ";
        //cout<<"\n";
        FOR(j,1,n+1) mn=min(mn,mx);
    }
    cout<<mn<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 126 ms 344 KB Output is correct
2 Correct 114 ms 344 KB Output is correct
3 Correct 122 ms 344 KB Output is correct
4 Correct 125 ms 428 KB Output is correct
5 Correct 128 ms 348 KB Output is correct
6 Correct 126 ms 428 KB Output is correct
7 Correct 121 ms 432 KB Output is correct
8 Correct 124 ms 436 KB Output is correct
9 Correct 127 ms 432 KB Output is correct
10 Correct 113 ms 348 KB Output is correct
11 Correct 113 ms 348 KB Output is correct
12 Correct 125 ms 436 KB Output is correct
13 Correct 123 ms 432 KB Output is correct
14 Correct 121 ms 436 KB Output is correct
15 Correct 128 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 344 KB Output is correct
2 Correct 114 ms 344 KB Output is correct
3 Correct 122 ms 344 KB Output is correct
4 Correct 125 ms 428 KB Output is correct
5 Correct 128 ms 348 KB Output is correct
6 Correct 126 ms 428 KB Output is correct
7 Correct 121 ms 432 KB Output is correct
8 Correct 124 ms 436 KB Output is correct
9 Correct 127 ms 432 KB Output is correct
10 Correct 113 ms 348 KB Output is correct
11 Correct 113 ms 348 KB Output is correct
12 Correct 125 ms 436 KB Output is correct
13 Correct 123 ms 432 KB Output is correct
14 Correct 121 ms 436 KB Output is correct
15 Correct 128 ms 348 KB Output is correct
16 Incorrect 5 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 126 ms 344 KB Output is correct
2 Correct 114 ms 344 KB Output is correct
3 Correct 122 ms 344 KB Output is correct
4 Correct 125 ms 428 KB Output is correct
5 Correct 128 ms 348 KB Output is correct
6 Correct 126 ms 428 KB Output is correct
7 Correct 121 ms 432 KB Output is correct
8 Correct 124 ms 436 KB Output is correct
9 Correct 127 ms 432 KB Output is correct
10 Correct 113 ms 348 KB Output is correct
11 Correct 113 ms 348 KB Output is correct
12 Correct 125 ms 436 KB Output is correct
13 Correct 123 ms 432 KB Output is correct
14 Correct 121 ms 436 KB Output is correct
15 Correct 128 ms 348 KB Output is correct
16 Incorrect 5 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 126 ms 344 KB Output is correct
2 Correct 114 ms 344 KB Output is correct
3 Correct 122 ms 344 KB Output is correct
4 Correct 125 ms 428 KB Output is correct
5 Correct 128 ms 348 KB Output is correct
6 Correct 126 ms 428 KB Output is correct
7 Correct 121 ms 432 KB Output is correct
8 Correct 124 ms 436 KB Output is correct
9 Correct 127 ms 432 KB Output is correct
10 Correct 113 ms 348 KB Output is correct
11 Correct 113 ms 348 KB Output is correct
12 Correct 125 ms 436 KB Output is correct
13 Correct 123 ms 432 KB Output is correct
14 Correct 121 ms 436 KB Output is correct
15 Correct 128 ms 348 KB Output is correct
16 Incorrect 5 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 126 ms 344 KB Output is correct
2 Correct 114 ms 344 KB Output is correct
3 Correct 122 ms 344 KB Output is correct
4 Correct 125 ms 428 KB Output is correct
5 Correct 128 ms 348 KB Output is correct
6 Correct 126 ms 428 KB Output is correct
7 Correct 121 ms 432 KB Output is correct
8 Correct 124 ms 436 KB Output is correct
9 Correct 127 ms 432 KB Output is correct
10 Correct 113 ms 348 KB Output is correct
11 Correct 113 ms 348 KB Output is correct
12 Correct 125 ms 436 KB Output is correct
13 Correct 123 ms 432 KB Output is correct
14 Correct 121 ms 436 KB Output is correct
15 Correct 128 ms 348 KB Output is correct
16 Incorrect 5 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -