QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#608063 | #1140. Distributing Candies | winsun | 0 | 226ms | 40916kb | C++14 | 2.5kb | 2024-10-03 18:11:40 | 2024-10-03 18:11:40 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>
#define fi first
#define se second
using namespace std;
using LL = long long;
using LLL = __int128;
const int MAXN = 2e5+5;
int n, m;
vector<pair<int, int>> op[MAXN];
namespace SGT {
struct Node {
LL mx, mn, tag;
Node(LL a=0, LL b=0) {
mx = a, mn = b, tag = 0;
}
Node operator+(Node x) {
return Node(max(mx, x.mx), min(mn, x.mn));
}
void modify(LL v) {
mx += v, mn += v, tag += v;
}
} s[MAXN<<2];
void spread(int cur) {
if (!s[cur].tag) return;
s[cur<<1].modify(s[cur].tag), s[cur<<1|1].modify(s[cur].tag);
s[cur].tag = 0;
}
void update(int cur, int l, int r, int L, int R, LL v) {
if (L <= l && R >= r) return s[cur].modify(v);
spread(cur);
int mid = (l + r) >> 1;
if (L <= mid) update(cur<<1, l, mid, L, R, v);
if (R > mid) update(cur<<1|1, mid+1, r, L, R, v);
s[cur] = s[cur<<1] + s[cur<<1|1];
}
int queryBin(int cur, int l, int r, int c, Node& res) {
if (l == r) return res = res + s[cur], l;
spread(cur);
int mid = (l + r) >> 1;
Node rv = s[cur<<1|1] + res;
if (rv.mx - rv.mn > c) return queryBin(cur<<1|1, mid+1, r, c, res);
else return res = rv, queryBin(cur<<1, l, mid, c, res);
}
LL queryPos(int cur, int l, int r, int p) {
if (l == r) return s[cur].mx;
spread(cur);
int mid = (l + r) >> 1;
if (p <= mid) return queryPos(cur<<1, l, mid, p);
else return queryPos(cur<<1|1, mid+1, r, p);
}
}
vector<int> distribute_candies(vector<int> c,
vector<int> ql, vector<int> qr, vector<int> qv) {
vector<int> ans;
n = c.size(), m = ql.size();
for (int i = 0; i < m; ++i) {
op[ql[i]].push_back(make_pair(i, qv[i]));
op[qr[i]+1].push_back(make_pair(i, -qv[i]));
}
for (int i = 0; i < n; ++i) {
for (auto x:op[i]) SGT::update(1, 0, m, x.fi+1, m, x.se);
SGT::Node res(-2e9, 2e9);
int p = SGT::queryBin(1, 0, m, c[i], res);
LL ed = SGT::queryPos(1, 0, m, m);
int cur = 0;
if (res.mx - res.mn <= c[i]) cur = ed - min(0ll, res.mn);
else if (res.mx == SGT::queryPos(1, 0, m, p)) cur = ed - res.mn;
else cur = ed - res.mx + c[i];
ans.push_back(cur);
}
return ans;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 27236kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 8 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 8 0 7 1 0 7 1 0 7 300000000 0 7 994967293 0 7 1 0 7 1000000000 0 7 1000000000 0 7 1000000000
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK -2000000000 -2000000000 -2000000000 -2000000000 -2000000000 -2000000000 -2000000000 -2000000000
result:
wrong answer 3rd lines differ - expected: '1000000000 1000000000 10000000...000000000 1000000000 1000000000', found: '-2000000000 -2000000000 -20000...0000000 -2000000000 -2000000000'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 226ms
memory: 40916kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 200000 11408901 370732653 37843 28 53693 15782410 103 297546 1112427 170319071 26 1 6172 11614171 431 884673599 1 3 50085 154 57 28200 145886 898969 74758 72 845768 6 69787 11 31012465 55362 253 2363145 47186217 1103 19622 594 7867 1 4299 28130 48 4689582 12 ...
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK 87153 87153 37843 28 53693 406667 103 297546 766665 971468 26 1 6172 1257294 431 1536484 1 3 50085 154 57 28200 145886 898969 74758 72 845768 6 69787 11 3043755 55362 253 2363145 3459533 1103 19622 594 7867 1 4299 28130 48 4317336 12 431 123 4531465 4806 3...
result:
wrong answer 3rd lines differ - expected: '87153 87153 37843 28 53693 406...46468 9 1756 429030 247071 1629', found: '87153 87153 37843 28 53693 406...46468 9 1756 429030 247071 1629'
Subtask #3:
score: 0
Wrong Answer
Test #9:
score: 27
Accepted
time: 3ms
memory: 27220kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000...
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 3 lines
Test #10:
score: 0
Wrong Answer
time: 122ms
memory: 35732kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 2000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK 1049802 936230 884511 204101 406074 550834 961642 2076245 1975297 2101513 2254310 1990108 1398298 1917785 2864344 2475931 2270774 401698970 402327667 402506418 401068637 399388438 398687119 398672863 397137012 397262070 396255448 395961553 394643443 394646...
result:
wrong answer 3rd lines differ - expected: '1049802 936230 884511 204101 4...877 441728121 110945553 1330162', found: '1049802 936230 884511 204101 4...877 441728121 110945553 1330162'
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 29
Accepted
time: 2ms
memory: 27464kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 10 11 440 51 41 11 1 3 108 148 14 10 0 9 60 0 9 -9 0 9 -30 0 9 41 0 9 82 0 9 69 0 9 -79 0 9 -39 0 9 72 0 9 41
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK 11 208 51 41 11 1 3 108 143 14
result:
ok 3 lines
Test #17:
score: 29
Accepted
time: 0ms
memory: 27224kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 1000 6 129 1 3 18 414 46 7 33 2 29 3 395 143 120 62 343 102 568 40 49 1 37 7 31 66 12 1 330 4 3 10 3 216 2 375 15 786 1 156 243 411 519 14 13 13 667 2 382 294 1 556 53 2 368 1 32 5 201 13 376 369 91 11 14 5 584 65 3 443 1 989 889 22 8 177 140 7 481 6 371 142 ...
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 3 lines
Test #18:
score: 29
Accepted
time: 55ms
memory: 34668kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 2000 4207825 17466917 11 20 10489 1278831 48720 43780703 37223309 28500011 76204785 631 321 1650 263304936 1382 1900 1 225756109 43424483 21143 218062355 851196097 633450 141629084 11494 1 19 12133 5908567 7 26138 1131 152662321 18 787906 312 11463 393 109417...
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK 780706 1955314 11 20 10489 659178 48720 1955314 1955314 1955314 1955314 631 321 1650 1955314 1382 1900 1 1955314 1955314 21143 1955314 1955314 633450 1955314 11494 1 19 12133 1691591 7 26138 1131 1955314 18 659178 312 11463 393 659178 659178 1180 1955314 5...
result:
ok 3 lines
Test #19:
score: 29
Accepted
time: 43ms
memory: 29556kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 200000 401 38224076 293 9 2873526 11 356842329 318925257 728 169 749704686 13312846 8 6106116 4 379784 2 678669 1104 1268657 4579072 4620407 111763 117481111 81224 415449128 69269056 62353747 592 998 1135181 7443857 5706444 6 2 11 87555 3780941 72 8 407 11455...
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK 0 2136442 0 0 1590745 0 2136442 2136442 0 0 2136442 2136442 0 2136442 0 120361 0 120361 0 120361 2136442 2136442 24468 2136442 0 2136442 2136442 2136442 0 0 120361 2136442 2136442 0 0 0 260 2136442 0 0 0 0 2136442 0 0 0 1210287 2136442 2136442 0 2136442 0 ...
result:
ok 3 lines
Test #20:
score: 29
Accepted
time: 103ms
memory: 37804kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 200000 2 607917 87 7743038 272 19678 1 98 439 30 7898 262 2631381 23073 1026097 3698 6614 40 442324 168 3 43717 2370 1627514 8316081 398 1882901 1 42496 1 20135 29167 4032 6305 3894321 170 598 492 9418417 74322 2401853 52 42 31 145771 1720 63583 100 270 4249 ...
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK 2 56203 87 56203 148 12145 1 98 179 30 1408 148 56203 15540 56203 179 1408 40 56203 148 3 17751 179 56203 56203 179 56203 1 17751 1 12602 17751 179 1408 56203 148 179 179 56203 44280 56203 52 42 31 56203 179 33541 100 148 179 179 22 56203 56203 31 16 4 140...
result:
ok 3 lines
Test #21:
score: 29
Accepted
time: 100ms
memory: 38060kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 200000 11408901 370732653 37843 28 53693 15782410 103 297546 1112427 170319071 26 1 6172 11614171 431 884673599 1 3 50085 154 57 28200 145886 898969 74758 72 845768 6 69787 11 31012465 55362 253 2363145 47186217 1103 19622 594 7867 1 4299 28130 48 4689582 12 ...
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK 6103361 10904843 17 17 17 6103361 17 17 17 10904843 17 1 17 6103361 17 10904843 1 3 17 17 17 17 17 17 17 17 17 6 17 11 10904843 17 17 515937 10904843 17 17 17 17 1 17 17 17 515937 12 17 17 10904843 17 17 17 1 1 10904843 10904843 17 17 2 17 17 17 1 515937 1...
result:
ok 3 lines
Test #22:
score: 0
Wrong Answer
time: 104ms
memory: 37804kb
input:
lrts0z0ktpqc670i0etyqgyb45dt1dysq5ap2mzg 200000 305263 281 10690 235 990069 52806771 124403 6 22 4901 18 4667 1944046 163079 358062945 167 258980 119407 434894470 51581578 40072504 9499993 3863 1269 1659 3 4 954 67916 18536 57095396 7 19561069 6 51690 595643338 5 902269 249 15 4526 1326847 3474 4157...
output:
4lpv73iykswp9e3nppi3jw2qggm5dfz29yy9nzpq OK -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -1815529700 -181...
result:
wrong answer 3rd lines differ - expected: '305263 281 10690 235 990069 52...65 196264 40903 42201659 274505', found: '-1815529700 -1815529700 -18155...5529700 -1815529700 -1815529700'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%