Submission #493769

#TimeUsernameProblemLanguageResultExecution timeMemory
493769vulpesCity (BOI06_city)C++17
90 / 100
1092 ms16720 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...