Submission #730085

# Submission time Handle Problem Language Result Execution time Memory
730085 2023-04-25T08:41:47 Z thimote75 City (BOI06_city) C++14
90 / 100
1000 ms 16820 KB
#include <bits/stdc++.h>

using namespace std;

#define num long long
#define vn vector<num>
#define ph pair<num, pair<int, int>>
#define sp priority_queue<ph, vector<ph>, greater<ph>>
#define stage second.second
#define dist second.first
#define cost first

vn costs;
num N, T;
int K;
sp current;

ph next (ph &x) {
    int s = x.stage + 1;
    int d = x.dist;
    num c = d * T + costs[s];

    return { c, { d, s } };
}
ph create (int d) {
    return { d * T + costs[0], { d, 0 } };
}
num count (int d) {
    return 4 * d + 4;
}

int main () {
    cin >> N >> T >> K;
    costs.resize(K);
    for (int i = 0; i < K; i ++) cin >> costs[i];

    current.push(create(0));

    num ans = 0;

    int i = 0;
    while (N > 0) {
        ph res = current.top();
        current.pop();

        if (res.stage + 1 != K)
            current.push(next(res));
        if (res.stage == 0)
            current.push(create(res.dist + 1));
        
        num size = min(count(res.dist), N);
        N -= size;

        ans += size * res.cost;
    }

    cout << ans << endl;
}

Compilation message

city.cpp: In function 'int main()':
city.cpp:42:9: warning: unused variable 'i' [-Wunused-variable]
   42 |     int i = 0;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 92 ms 16820 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 86 ms 356 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Execution timed out 1079 ms 660 KB Time limit exceeded
8 Correct 258 ms 368 KB Output is correct
9 Correct 154 ms 352 KB Output is correct
10 Correct 0 ms 212 KB Output is correct