Submission #595024

#TimeUsernameProblemLanguageResultExecution timeMemory
595024piOOESemiexpress (JOI17_semiexpress)C++17
100 / 100
147 ms66148 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, m, k; cin >> n >> m >> k; ll a, b, c; cin >> a >> b >> c; //slow, fast, middle ll t; cin >> t; vector<ll> s(m); for (int i = 0; i < m; ++i) { cin >> s[i]; } vector<pair<ll, bool>> v; ll ans = 0; s.push_back(n + 1); for (int i = 0; i <= m; ++i) { ll dist = (s[i] - 1) * b; if (dist > t) { break; } ll x = s[i]; int cnt = 0; while (x < s[i + 1] && dist <= t && cnt < k) { ll nxt = (t - dist) / a; if (x + nxt + 1 >= s[i + 1]) { nxt = s[i + 1] - x - 1; } cnt += (x != s[i]); v.push_back({nxt + 1, x != s[i]}); dist += (nxt + 1) * c; x += nxt + 1; } } sort(v.begin(), v.end(), greater()); int cnt = m; for (int i = 0; i < v.size(); ++i) { if (cnt + v[i].second <= k) { ans += v[i].first; cnt += v[i].second; } } cout << ans - 1; return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i = 0; i < v.size(); ++i) {
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...