답안 #209707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209707 2020-03-15T10:30:11 Z dolphingarlic City (BOI06_city) C++14
90 / 100
1000 ms 25032 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

ll diff[20001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, t, k;
    cin >> n >> t >> k;
    FOR(i, 1, k + 1) {
        cin >> diff[i];
        diff[i - 1] -= diff[i];
    }

    priority_queue<tuple<ll, ll, ll>> pq;
    pq.push({diff[0], 1, 4});

    int dist = 1;
    ll ans = 0;
    while (n) {
        ll cost, level, capacity;
        tie(cost, level, capacity) = pq.top();
        pq.pop();

        capacity = min(n, capacity);
        ans -= cost * capacity;
        n -= capacity;

        if (level < k) pq.push({cost + diff[level], level + 1, capacity});
        if (!pq.size() || diff[0] - t * dist > get<0>(pq.top()))
            pq.push({diff[0] - t * dist++, 1, 4 * dist});
    }
    cout << ans;
    return 0;
}

Compilation message

city.cpp: In function 'int main()':
city.cpp:34:40: warning: operation on 'dist' may be undefined [-Wsequence-point]
             pq.push({diff[0] - t * dist++, 1, 4 * dist});
                                    ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 130 ms 25032 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 118 ms 504 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Execution timed out 1082 ms 888 KB Time limit exceeded
8 Correct 326 ms 504 KB Output is correct
9 Correct 200 ms 508 KB Output is correct
10 Correct 5 ms 376 KB Output is correct