답안 #21337

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
21337 2017-04-13T10:31:15 Z Ushio Arranging Tickets (JOI17_arranging_tickets) C++14
0 / 100
0 ms 1844 KB
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int INF = 0x3f3f3f3f;
const int NMAX = 6007;

int C[NMAX][NMAX], F[NMAX][NMAX];
vector<int> G[NMAX];

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    vector<int> left(m), right(m);
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> left[i] >> right[i] >> x;
        if (left[i] > right[i]) {
            swap(left[i], right[i]);
        }
        left[i]--; right[i]--;
    }

    int ans = INF;
    for (int conf = 0; conf < (1 << m); ++conf) {
        vector<int> cnt(n, 0);
        for (int i = 0; i < m; ++i) {
            if (conf & (1 << i)) {
                cnt[0]++;
                cnt[left[i]]--;
                cnt[right[i]]++;
            } else {
                cnt[left[i]]++;
                cnt[right[i]]--;
            }
        }
        for (int i = 1; i < n; ++i) {
            cnt[i] += cnt[i - 1];
        }
        ans = min(ans, *max_element(cnt.begin(), cnt.end()));
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -