답안 #140581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
140581 2019-08-03T15:52:49 Z khrbuddy03 택배 (KOI13_delivery) C++14
100 / 100
18 ms 888 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<pair<int, int>, int> vil;
int n, c, m, load[2009];
vector<vil> vils;

bool cmp(const vil& v1, const vil& v2) {
    if (v1.first.second == v2.first.second) return v1.first.first < v2.first.first;
    return v1.first.second < v2.first.second;
}

int main() {
    // freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> c >> m;
    for (int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        vils.push_back(make_pair(make_pair(a, b), c));
    }
    sort(vils.begin(), vils.end(), cmp);
    int ans = 0;
    for (int i = 0; i < m; i++) {
        int mbox = 0;
        for (int j = vils[i].first.first; j < vils[i].first.second; j++) {
            mbox = max(mbox, load[j]);
        }
        int tmp = min(vils[i].second, c - mbox);
        for (int j = vils[i].first.first; j < vils[i].first.second; j++) {
            load[j] += tmp;
        }
        ans += tmp;
    }
    cout << ans << '\n';
}


# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 424 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 17 ms 776 KB Output is correct
4 Correct 17 ms 888 KB Output is correct
5 Correct 18 ms 760 KB Output is correct