Submission #493769

# Submission time Handle Problem Language Result Execution time Memory
493769 2021-12-13T00:08:51 Z vulpes City (BOI06_city) C++17
90 / 100
1000 ms 16720 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll t, c[20007];

bool cmp(pair<ll,ll> a, pair<ll,ll> b) {
    return a.first * t + c[a.second] >
           b.first * t + c[b.second];
}

int main() {
    ll n, k; scanf("%lld%lld%lld", &n, &t, &k);
    for (int i = 0; i < k; i++) {
        scanf("%lld", &c[i]);
    }
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, decltype(&cmp)> q(cmp);
    ll r = 0, d = 1; q.push({0, 0});
    while (n) {
        pair<ll,ll> h = q.top(); q.pop();
        ll z = min(n, 4 * (h.first + 1)); n -= z;
        r += z * (h.first * t + c[h.second]);
        if (h.second + 1 < k) {
            q.push({h.first, h.second + 1});
        }
        if (q.empty() || !cmp({d, 0}, q.top())) {
            q.push({d++, 0});
        }
    }
    printf("%lld", r); 
}

Compilation message

city.cpp: In function 'int main()':
city.cpp:13:19: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     ll n, k; scanf("%lld%lld%lld", &n, &t, &k);
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
city.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld", &c[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 178 ms 16720 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 87 ms 352 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Execution timed out 1092 ms 476 KB Time limit exceeded
8 Correct 311 ms 332 KB Output is correct
9 Correct 206 ms 324 KB Output is correct
10 Correct 0 ms 204 KB Output is correct