#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
using namespace std;
const int N = 1e6+10;
const ll inf = 1e18+10;
ll x, n, m, w, t, ans;
ll s[N];
pair <ll, ll> p[N];
bool u[N];
int main() {
cin >> x >> n >> m >> w >> t;
for(int i = 1; i <= n; i++)
cin >> s[i];
for(int i = 1; i <= m; i++) {
cin >> p[i].fr >> p[i].sc;
if(x > p[i].fr) {
ll xx = x - p[i].fr;
ans += w * ((xx / t) + 1);
}
}
ans += w * ((x / t) + 1);
sort(p + 1, p + m + 1);
sort(s + 1, s + n + 1);
s[++n] = x;
for(int i = 1; i <= n; i++) {
ll xx = s[i] % t, yy = s[i] / t;
ll pp = 0, ss = 0, mi = 0, mn = m + 1, rr = m + 1;
for(int j = m; j >= 1; j--) {
if(xx < p[j].fr) rr = j;
if(u[j] || xx < p[j].fr) continue;
pp += p[j].sc;
ss -= w * (((x - p[j].fr) / t) + 1 - yy);
if(mi > ss + pp) {
mi = ss + pp;
mn = j;
}
}
for(int j = mn; j < rr; j++) u[j] = 1;
ans += mi;
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
3 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
520 KB |
Output is correct |
8 |
Correct |
4 ms |
520 KB |
Output is correct |
9 |
Correct |
3 ms |
572 KB |
Output is correct |
10 |
Correct |
3 ms |
704 KB |
Output is correct |
11 |
Correct |
2 ms |
704 KB |
Output is correct |
12 |
Correct |
2 ms |
704 KB |
Output is correct |
13 |
Correct |
4 ms |
704 KB |
Output is correct |
14 |
Correct |
2 ms |
704 KB |
Output is correct |
15 |
Correct |
2 ms |
752 KB |
Output is correct |
16 |
Correct |
2 ms |
756 KB |
Output is correct |
17 |
Correct |
2 ms |
756 KB |
Output is correct |
18 |
Correct |
3 ms |
756 KB |
Output is correct |
19 |
Correct |
3 ms |
768 KB |
Output is correct |
20 |
Correct |
2 ms |
768 KB |
Output is correct |
21 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
3 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
520 KB |
Output is correct |
8 |
Correct |
4 ms |
520 KB |
Output is correct |
9 |
Correct |
3 ms |
572 KB |
Output is correct |
10 |
Correct |
3 ms |
704 KB |
Output is correct |
11 |
Correct |
2 ms |
704 KB |
Output is correct |
12 |
Correct |
2 ms |
704 KB |
Output is correct |
13 |
Correct |
4 ms |
704 KB |
Output is correct |
14 |
Correct |
2 ms |
704 KB |
Output is correct |
15 |
Correct |
2 ms |
752 KB |
Output is correct |
16 |
Correct |
2 ms |
756 KB |
Output is correct |
17 |
Correct |
2 ms |
756 KB |
Output is correct |
18 |
Correct |
3 ms |
756 KB |
Output is correct |
19 |
Correct |
3 ms |
768 KB |
Output is correct |
20 |
Correct |
2 ms |
768 KB |
Output is correct |
21 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
3 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
520 KB |
Output is correct |
8 |
Correct |
4 ms |
520 KB |
Output is correct |
9 |
Correct |
3 ms |
572 KB |
Output is correct |
10 |
Correct |
3 ms |
704 KB |
Output is correct |
11 |
Correct |
2 ms |
704 KB |
Output is correct |
12 |
Correct |
2 ms |
704 KB |
Output is correct |
13 |
Correct |
4 ms |
704 KB |
Output is correct |
14 |
Correct |
2 ms |
704 KB |
Output is correct |
15 |
Correct |
2 ms |
752 KB |
Output is correct |
16 |
Correct |
2 ms |
756 KB |
Output is correct |
17 |
Correct |
2 ms |
756 KB |
Output is correct |
18 |
Correct |
3 ms |
756 KB |
Output is correct |
19 |
Correct |
3 ms |
768 KB |
Output is correct |
20 |
Correct |
2 ms |
768 KB |
Output is correct |
21 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
3 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
520 KB |
Output is correct |
8 |
Correct |
4 ms |
520 KB |
Output is correct |
9 |
Correct |
3 ms |
572 KB |
Output is correct |
10 |
Correct |
3 ms |
704 KB |
Output is correct |
11 |
Correct |
2 ms |
704 KB |
Output is correct |
12 |
Correct |
2 ms |
704 KB |
Output is correct |
13 |
Correct |
4 ms |
704 KB |
Output is correct |
14 |
Correct |
2 ms |
704 KB |
Output is correct |
15 |
Correct |
2 ms |
752 KB |
Output is correct |
16 |
Correct |
2 ms |
756 KB |
Output is correct |
17 |
Correct |
2 ms |
756 KB |
Output is correct |
18 |
Correct |
3 ms |
756 KB |
Output is correct |
19 |
Correct |
3 ms |
768 KB |
Output is correct |
20 |
Correct |
2 ms |
768 KB |
Output is correct |
21 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |