QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#544038 | #8257. Marathon Race 2 | Bucketsmith | 7 | 3ms | 9108kb | C++20 | 1.3kb | 2024-09-02 01:04:56 | 2024-09-02 01:04:56 |
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int N = 5e5 + 10;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, L, lm, rm;
cin >> n >> L;
vector<int> pb(L + 1);
vector<i64> pd(L + 1);
lm = L;
rm = 0;
for(int i = 1, x; i <= n; i ++) {
cin >> x;
pb[x] ++;
pd[x] += x;
lm = min(lm, x);
rm = max(rm, x);
}
for(int i = 1; i <= L; i ++) {
pb[i] += pb[i - 1];
pd[i] += pd[i - 1];
}
int q;
cin >> q;
for(int _ = 1, s, g; _ <= q; _ ++) {
i64 t;
cin >> s >> g >> t;
t -= n;
if(s <= g) {
t -= abs(s - lm) + abs(rm - lm) + abs(g - rm);
t -= pd[L] + pb[L] * (i64)g;
if(g > 0) {
t += pd[g - 1] + pb[g - 1] * (i64)g;
t -= (rm + abs(g - rm)) * (i64)pb[g - 1] - pd[g - 1];
}
}else{
t -= abs(s - rm) + abs(rm - lm) + abs(g - lm);
t -= pb[g] * (i64)g - pd[g];
t -= (pb[L] - pb[g]) * (g - 2ll * lm) + (pd[L] - pd[g]);
}
cout << (t >= 0 ? "Yes" : "No") << "\n";
}
}
/*
3 100
30 80 30
3
0 0 403
0 0 300
0 0 262
6 100
0 50 100 0 50 100
4
20 70 600
70 20 600
10 40 600
40 10 600
*/
詳細信息
Subtask #1:
score: 7
Accepted
Test #1:
score: 7
Accepted
time: 3ms
memory: 9108kb
input:
1 500000 166666 10 0 0 500000 0 0 499999 0 0 499998 0 0 499997 0 0 499996 0 0 5 0 0 4 0 0 3 0 0 2 0 0 1
output:
Yes Yes No No No No No No No No
result:
ok 10 token(s): yes count is 2, no count is 8
Test #2:
score: 7
Accepted
time: 3ms
memory: 9064kb
input:
1 500000 0 10 0 0 500000 0 0 499999 0 0 499998 0 0 499997 0 0 499996 0 0 5 0 0 4 0 0 3 0 0 2 0 0 1
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
result:
ok 10 token(s): yes count is 10, no count is 0
Test #3:
score: 7
Accepted
time: 0ms
memory: 3560kb
input:
2 1 0 1 10 0 0 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10
output:
No No No No Yes Yes Yes Yes Yes Yes
result:
ok 10 token(s): yes count is 6, no count is 4
Test #4:
score: 7
Accepted
time: 1ms
memory: 3576kb
input:
3 1 0 0 1 10 0 0 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10
output:
No No No No No Yes Yes Yes Yes Yes
result:
ok 10 token(s): yes count is 5, no count is 5
Test #5:
score: 7
Accepted
time: 0ms
memory: 3856kb
input:
1 1 0 10 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
result:
ok 10 token(s): yes count is 10, no count is 0
Test #6:
score: 7
Accepted
time: 1ms
memory: 4184kb
input:
7 83382 35565 7347 27797 28072 31528 45377 43857 10 0 0 160004 0 0 224969 0 0 310304 0 0 354202 0 0 310303 0 0 493150 0 0 227687 0 0 448225 0 0 88396 0 0 155211
output:
No No Yes Yes No Yes No Yes No No
result:
ok 10 token(s): yes count is 4, no count is 6
Test #7:
score: 7
Accepted
time: 1ms
memory: 4100kb
input:
7 83382 35212 3869 11565 53219 2927 45479 40671 10 0 0 189926 0 0 419739 0 0 245553 0 0 110218 0 0 299387 0 0 1986 0 0 473275 0 0 195521 0 0 299386 0 0 246039
output:
No Yes No No Yes No Yes No No No
result:
ok 10 token(s): yes count is 3, no count is 7
Test #8:
score: 7
Accepted
time: 0ms
memory: 8992kb
input:
7 500000 6069 96930 28374 1275 53141 1423 6225 10 0 0 388080 0 0 73883 0 0 319880 0 0 141926 0 0 144641 0 0 67306 0 0 387304 0 0 387303 0 0 236649 0 0 130438
output:
Yes No No No No No Yes No No No
result:
ok 10 token(s): yes count is 2, no count is 8
Test #9:
score: 7
Accepted
time: 3ms
memory: 9080kb
input:
7 500000 22379 39203 896 17806 23724 7599 153 10 0 0 492328 0 0 190173 0 0 315557 0 0 190172 0 0 138962 0 0 298883 0 0 246521 0 0 194070 0 0 252592 0 0 418531
output:
Yes Yes Yes No No Yes Yes Yes Yes Yes
result:
ok 10 token(s): yes count is 8, no count is 2
Test #10:
score: 7
Accepted
time: 0ms
memory: 9064kb
input:
7 500000 0 0 0 0 0 0 0 10 0 0 124229 0 0 233729 0 0 306668 0 0 499999 0 0 220256 0 0 62117 0 0 115533 0 0 48137 0 0 160004 0 0 500000
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
result:
ok 10 token(s): yes count is 10, no count is 0
Test #11:
score: 7
Accepted
time: 0ms
memory: 9092kb
input:
7 498000 498000 498000 498000 498000 498000 498000 498000 10 0 0 261154 0 0 235539 0 0 224636 0 0 283789 0 0 500000 0 0 480913 0 0 326331 0 0 499999 0 0 61700 0 0 280564
output:
No No No No No No No No No No
result:
ok 10 token(s): yes count is 0, no count is 10
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #12:
score: 0
Wrong Answer
time: 0ms
memory: 3860kb
input:
1 2 1 8 0 0 3 0 0 4 0 2 3 0 2 4 2 0 3 2 0 4 2 2 3 2 2 4
output:
No Yes No Yes Yes Yes No Yes
result:
wrong answer expected NO, found YES [5th token]
Subtask #3:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%