QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#311472 | #8016. 不休陀螺 | KiharaTouma | 0 | 268ms | 43492kb | C++23 | 1.7kb | 2024-01-22 13:50:16 | 2024-01-22 13:50:16 |
Judging History
answer
//qoj8016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e6 + 10;
//priority_queue<ll> q, qq;
int n, m, bit[N], E, a[N], b[N], c[N], d[N];
ll sum[N], k[N];
void read(int &x){
x = 0;
char ch = getchar();
int w = 1;
while(ch < '0' || ch > '9'){
if(ch == '-'){
w = -w;
}
ch = getchar();
}
while(ch >= '0' && ch <= '9'){
x = x * 10 + ch - '0';
ch = getchar();
}
x *= w;
}
void add(int x, int v){
while(x <= m){
bit[x] += v;
x += x & -x;
}
}
int ask(int x){
int res = 0;
while(x){
res += bit[x];
x -= x & -x;
}
return res;
}
multiset<ll> s;
int main(){
read(n);
read(E);
for(int i = 1; i <= n; ++ i){
read(a[i]);
}
for(int i = 1; i <= n; ++ i){
read(b[i]);
sum[i] = sum[i-1] + b[i] - a[i];
c[i] = min(b[i] - a[i], 0);
d[i] = min(b[i], a[i]);
k[i] = sum[i];
}
sort(k + 1, k + n + 2);
m = unique(k + 1, k + n + 2) - k - 1;
for(int i = 0; i <= n; ++ i){
sum[i] = lower_bound(k + 1, k + m + 1, sum[i]) - k;
}
ll ne = E, ans = 0;
ll mx = -1e18;
// q.push(-1e18);
s.insert(-1e18);
for(int l = 1, r = 1; l <= n; ++ l){
r = max(r, l-1);
while(r <= n){
if(ne + c[r] >= max(mx, (ll)d[r])){
ne += c[r];
s.insert(d[r]);
// q.push(d[r]);
add(m-sum[r]+1, 1);
mx = max(mx, (ll)d[r]);
++ r;
} else {
break;
}
}
ans += ask(m-sum[l]+1);
ne -= c[l];
auto p = s.find(d[l]);
s.erase(p);
// qq.push(d[l]);
add(m-sum[l]+1, -1);
// while(!qq.empty() && !q.empty() && q.top() == qq.top()){
// q.pop();
// qq.pop();
// }
// mx = q.top();
p = s.end();
-- p;
mx = *p;
}
printf("%lld\n", ans);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 14084kb
input:
5000 939255322 47952340 92329911 61615795 40122788 47258178 29326499 9822850 42767362 86610596 60318756 52429688 87502511 50194916 96377063 74322128 19511341 28794957 53813791 79075058 35555414 5249682 45174421 101856091 25257909 94697470 45853817 82945426 108415825 41731145 87133877 75167193 598696...
output:
1849092
result:
wrong answer 1st lines differ - expected: '1846283', found: '1849092'
Subtask #2:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 268ms
memory: 43492kb
input:
774484 763692678 47702350 34856775 28447988 4178162 45063720 8232662 36845607 27038945 44858289 5952529 39159657 21628528 60199611 5544054 59216841 39287087 43449994 20034684 56440004 11583811 44465341 32347476 49196492 22731571 9481143 11726859 35167370 23103544 23109378 38822668 29778048 58004104 ...
output:
124399749
result:
wrong answer 1st lines differ - expected: '124023429', found: '124399749'
Subtask #3:
score: 0
Runtime Error
Test #10:
score: 0
Runtime Error
input:
1000000 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
result:
Subtask #4:
score: 0
Wrong Answer
Test #14:
score: 0
Wrong Answer
time: 38ms
memory: 20792kb
input:
174457 888 0 0 0 0 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 0 0 1 0 1 0 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 0 1 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1 0 1 0 0 1 1...
output:
329886383
result:
wrong answer 1st lines differ - expected: '329807918', found: '329886383'
Subtask #5:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 96ms
memory: 28064kb
input:
343922 773619774 0 8292680 5684115 0 0 170056 5385926 0 0 1588575 0 0 10947891 170867 35145 0 0 103085 7231562 0 0 0 0 11128944 0 4872226 0 2879880 7565181 0 8631665 0 5162564 9511835 514165 0 9628987 14357934 174784 0 12400154 0 0 8198218 0 8496060 0 0 0 0 10376826 3523227 0 14548249 0 6840016 0 0 ...
output:
36271193
result:
wrong answer 1st lines differ - expected: '36107528', found: '36271193'
Subtask #6:
score: 0
Wrong Answer
Test #24:
score: 0
Wrong Answer
time: 187ms
memory: 31808kb
input:
468676 582048177 6889433 7293342 20676061 15545414 4911497 12352219 8921719 1705801 19695926 25259227 2645394 17518171 19753552 9449377 982708 22479531 1267985 15594372 20685422 9627290 2017543 6459134 18614020 16206301 14962487 12932255 7101003 29140540 6479702 20607124 2540287 15565156 20274141 11...
output:
353507316
result:
wrong answer 1st lines differ - expected: '353280708', found: '353507316'