Submission #50263

#TimeUsernameProblemLanguageResultExecution timeMemory
50263gs13105Semiexpress (JOI17_semiexpress)C++17
100 / 100
18 ms3536 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <iterator> using namespace std; int arr[3010]; vector<int> mem[3010]; struct str { int x, y; bool operator <(const str &a) const { return mem[x][y] < mem[a.x][a.y]; } }; int main() { //freopen("in", "r", stdin); //freopen("out", "w", stdout); int n, m, k, a, b, c, i, j; long long t; scanf("%d%d%d%d%d%d%lld", &n, &m, &k, &a, &b, &c, &t); for(i = 0; i < m; i++) scanf("%d", &arr[i]); k -= m; priority_queue<str> pq; int r = -1; for(i = 0; i < m - 1; i++) { long long t2 = t - 1LL * b * (arr[i] - 1); int sum = 0; for(j = 0; t2 >= 0 && j <= k; j++) { long long x = 1 + t2 / a; if(x + sum >= arr[i + 1] - arr[i]) { mem[i].push_back(arr[i + 1] - arr[i] - sum); break; } mem[i].push_back(x); sum += x; t2 -= 1LL * c * x; } if(mem[i].size() >= 1) { r += mem[i][0]; if(mem[i].size() >= 2) pq.push({ i, 1 }); } } if(1LL * b * (n - 1) <= t) r++; for(i = 0; !pq.empty() && i < k; i++) { str p = pq.top(); pq.pop(); r += mem[p.x][p.y]; if(p.y + 1 < mem[p.x].size()) pq.push({ p.x, p.y + 1 }); } printf("%d\n", r); return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:81:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(p.y + 1 < mem[p.x].size())
            ~~~~~~~~^~~~~~~~~~~~~~~~~
semiexpress.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d%d%d%lld", &n, &m, &k, &a, &b, &c, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...