Submission #556837

#TimeUsernameProblemLanguageResultExecution timeMemory
556837Ai7081Semiexpress (JOI17_semiexpress)C++17
0 / 100
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 3005; ll n, m, k, s[N], ans, a, b, c, t; priority_queue<ll, vector<ll>, greater<ll>> pq; void add(ll x) { pq.push(x); if (pq.size() > k) pq.pop(); } int main() { scanf(" %lld %lld %lld", &n, &m, &k); scanf(" %lld %lld %lld", &a, &b, &c); scanf(" %lld", &t); k -= m; for (int i=1; i<=m; i++) scanf(" %lld", &s[i]); ans += (t/b >= n); for (int i=1; i<m && t>=0; i++) { ans += min(s[i+1]-s[i]-1, t/a) + (i!=1); ll now = min(s[i+1], s[i]+t/a+1), pre=0, tmp=k; while (now < s[i+1] && tmp--) { pre = now; ll t_left = t - (pre - s[i]) * c; if (t_left < 0) break; now = min(pre + t_left/a, s[i+1]-1); add(now - pre + 1); now++; } t -= (s[i+1] - s[i]) * b; } while (!pq.empty()) { if (pq.top() >0) ans += pq.top(); pq.pop(); } printf("%lld", ans); return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'void add(long long int)':
semiexpress.cpp:12:19: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   12 |     if (pq.size() > k) pq.pop();
      |         ~~~~~~~~~~^~~
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf(" %lld %lld %lld", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf(" %lld %lld %lld", &a, &b, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf(" %lld", &t);
      |     ~~~~~^~~~~~~~~~~~~
semiexpress.cpp:20:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     for (int i=1; i<=m; i++) scanf(" %lld", &s[i]);
      |                              ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...