QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#125570 | #6531. Base Station Construction | zyoobn | WA | 50ms | 7916kb | C++20 | 761b | 2023-07-16 21:59:18 | 2023-07-16 21:59:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int m;
cin >> m;
vector<vector<int>> g(n);
for (int i = 0; i < m; ++i) {
int l, r;
cin >> l >> r;
--l, --r;
g[r].push_back(l);
}
vector<i64> dp(n);
priority_queue<int> q;
for (int i = 0; i < n; ++i) {
if (!q.empty()) {
dp[i] = dp[q.top()] + a[i];
} else {
dp[i] = a[i];
}
for (auto &l : g[i]) {
q.push(l);
}
}
cout << dp[n - 1] << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while(t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3444kb
input:
2 5 3 2 4 1 100 3 1 3 2 4 5 5 5 7 3 4 2 2 3 1 4 2 3 4 5
output:
102 5
result:
ok 2 number(s): "102 5"
Test #2:
score: -100
Wrong Answer
time: 50ms
memory: 7916kb
input:
6201 12 88 78 46 95 84 98 55 3 68 42 6 18 19 6 9 10 11 12 12 8 11 8 12 2 3 2 3 1 5 9 9 7 8 6 11 2 4 12 12 2 4 2 9 7 10 8 8 1 7 6 11 5 76 27 48 66 61 2 1 4 3 5 8 64 81 20 6 86 9 4 55 1 7 7 9 1 43 18 81 11 22 9 61 83 14 5 6 2 6 5 8 1 4 9 9 9 9 7 7 2 5 8 9 5 6 4 8 5 8 9 9 6 6 10 66 41 84 7 80 31 22 96 ...
output:
209 137 59 157 362 141 64 220 174 139 245 206 217 162 230 127 287 89 156 130 148 144 100 193 299 111 239 303 236 150 177 57 59 102 157 128 83 160 151 62 35 168 156 81 171 290 110 242 126 121 335 86 311 244 333 162 302 177 304 238 30 129 75 131 96 179 81 382 142 185 119 176 215 373 301 124 120 78 234...
result:
wrong answer 1st numbers differ - expected: '141', found: '209'