답안 #1071397

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071397 2024-08-23T07:09:13 Z thinknoexit Arranging Tickets (JOI17_arranging_tickets) C++17
10 / 100
202 ms 600 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int l[22], r[22], c[22], l1[22], r1[22];
int qs[22];
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 0;i < m;i++) {
        cin >> l[i] >> r[i] >> c[i];
        if (l[i] > r[i]) {
            swap(l[i], r[i]);
        }
    }
    int ans = n;
    for (int i = 0;i < (1 << m);i++) {
        int mx = 0;
        memset(qs, 0, sizeof qs);
        for (int j = 0;j < m;j++) {
            l1[j] = l[j], r1[j] = r[j];
            if (i & (1 << j)) {
                swap(l1[j], r1[j]);
            }
        }
        for (int j = 0;j < m;j++) {
            if (l1[j] > r1[j]) {
                qs[l1[j]]++;
                qs[1]++;
                qs[r1[j]]--;
            }
            else {
                qs[l1[j]]++;
                qs[r1[j]]--;
            }
        }
        for (int i = 1;i <= n;i++) {
            qs[i] += qs[i - 1];
            mx = max(mx, qs[i]);
        }
        ans = min(ans, mx);
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 183 ms 348 KB Output is correct
2 Correct 185 ms 436 KB Output is correct
3 Correct 182 ms 348 KB Output is correct
4 Correct 175 ms 348 KB Output is correct
5 Correct 176 ms 436 KB Output is correct
6 Correct 179 ms 436 KB Output is correct
7 Correct 174 ms 344 KB Output is correct
8 Correct 184 ms 348 KB Output is correct
9 Correct 180 ms 436 KB Output is correct
10 Correct 202 ms 348 KB Output is correct
11 Correct 189 ms 348 KB Output is correct
12 Correct 184 ms 432 KB Output is correct
13 Correct 185 ms 344 KB Output is correct
14 Correct 170 ms 344 KB Output is correct
15 Correct 188 ms 428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 183 ms 348 KB Output is correct
2 Correct 185 ms 436 KB Output is correct
3 Correct 182 ms 348 KB Output is correct
4 Correct 175 ms 348 KB Output is correct
5 Correct 176 ms 436 KB Output is correct
6 Correct 179 ms 436 KB Output is correct
7 Correct 174 ms 344 KB Output is correct
8 Correct 184 ms 348 KB Output is correct
9 Correct 180 ms 436 KB Output is correct
10 Correct 202 ms 348 KB Output is correct
11 Correct 189 ms 348 KB Output is correct
12 Correct 184 ms 432 KB Output is correct
13 Correct 185 ms 344 KB Output is correct
14 Correct 170 ms 344 KB Output is correct
15 Correct 188 ms 428 KB Output is correct
16 Runtime error 1 ms 600 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 183 ms 348 KB Output is correct
2 Correct 185 ms 436 KB Output is correct
3 Correct 182 ms 348 KB Output is correct
4 Correct 175 ms 348 KB Output is correct
5 Correct 176 ms 436 KB Output is correct
6 Correct 179 ms 436 KB Output is correct
7 Correct 174 ms 344 KB Output is correct
8 Correct 184 ms 348 KB Output is correct
9 Correct 180 ms 436 KB Output is correct
10 Correct 202 ms 348 KB Output is correct
11 Correct 189 ms 348 KB Output is correct
12 Correct 184 ms 432 KB Output is correct
13 Correct 185 ms 344 KB Output is correct
14 Correct 170 ms 344 KB Output is correct
15 Correct 188 ms 428 KB Output is correct
16 Runtime error 1 ms 600 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 183 ms 348 KB Output is correct
2 Correct 185 ms 436 KB Output is correct
3 Correct 182 ms 348 KB Output is correct
4 Correct 175 ms 348 KB Output is correct
5 Correct 176 ms 436 KB Output is correct
6 Correct 179 ms 436 KB Output is correct
7 Correct 174 ms 344 KB Output is correct
8 Correct 184 ms 348 KB Output is correct
9 Correct 180 ms 436 KB Output is correct
10 Correct 202 ms 348 KB Output is correct
11 Correct 189 ms 348 KB Output is correct
12 Correct 184 ms 432 KB Output is correct
13 Correct 185 ms 344 KB Output is correct
14 Correct 170 ms 344 KB Output is correct
15 Correct 188 ms 428 KB Output is correct
16 Runtime error 1 ms 600 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 183 ms 348 KB Output is correct
2 Correct 185 ms 436 KB Output is correct
3 Correct 182 ms 348 KB Output is correct
4 Correct 175 ms 348 KB Output is correct
5 Correct 176 ms 436 KB Output is correct
6 Correct 179 ms 436 KB Output is correct
7 Correct 174 ms 344 KB Output is correct
8 Correct 184 ms 348 KB Output is correct
9 Correct 180 ms 436 KB Output is correct
10 Correct 202 ms 348 KB Output is correct
11 Correct 189 ms 348 KB Output is correct
12 Correct 184 ms 432 KB Output is correct
13 Correct 185 ms 344 KB Output is correct
14 Correct 170 ms 344 KB Output is correct
15 Correct 188 ms 428 KB Output is correct
16 Runtime error 1 ms 600 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -