ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214516 | #574. t3 | KXG | 0 | 50ms | 1908kb | C++11 | 1.3kb | 2024-11-19 19:47:12 | 2024-11-19 23:01:00 |
answer
#include <cstdio>
#include <deque>
using namespace std;
struct node {
int opt, x;
};
deque<node> dq;
int n;
long long x, y, z, ans;
int a[100010], b[100010];
int main() {
scanf("%d%lld%lld%lld", &n, &x, &y, &z);
for (int i = 1; i <= n; i++) {
scanf("%d%d", &a[i], &b[i]);
while (!dq.empty() && z * (i - dq.front().x) > x + y) {
if (dq.front().opt == 1) {
ans += y;
} else {
ans += x;
}
dq.pop_front();
}
while (a[i] < b[i] && !dq.empty() && dq.back().opt == 1) {
a[i]++;
ans += z * (i - dq.back().x);
dq.pop_back();
}
while (a[i] > b[i] && !dq.empty() && dq.back().opt == -1) {
a[i]--;
ans += z * (i - dq.back().x);
dq.pop_back();
}
while (a[i] < b[i]) {
a[i]++;
dq.push_back((node){-1, i});
}
while (a[i] > b[i]) {
a[i]--;
dq.push_back((node){1, i});
}
}
while (!dq.empty()) {
if (dq.front().opt == 1) {
ans += y;
} else {
ans += x;
}
dq.pop_front();
}
printf("%lld\n", ans);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1096kb
input:
50 4 401 83 1 9 0 10 1 1 7 5 6 2 6 10 5 10 5 5 4 4 10 8 8 3 4 8 8 0 1 2 8 9 9 9 4 6 8 7 3 10 2 4 9 3...
output:
13727
result:
wrong answer 1st words differ - expected: '12399', found: '13727'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 21ms
memory: 1908kb
input:
100000 100000000 100000000 1 4 1 7 1 7 6 7 5 7 5 6 6 5 1 1 4 2 0 3 0 5 7 1 9 1 1 6 8 2 5 7 7 7 9 6 3...
output:
211720592186
result:
wrong answer 1st words differ - expected: '211716275189', found: '211720592186'
Subtask #3:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 29ms
memory: 1884kb
input:
100000 30694440 93757838 144 1 4 0 5 9 3 3 8 6 9 7 4 3 5 6 1 6 6 4 5 10 0 9 4 7 4 9 1 5 4 8 4 2 0 10...
output:
12891090912
result:
wrong answer 1st words differ - expected: '11782941072', found: '12891090912'