QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#104723 | #6406. Stage Clear | gapinho# | WA | 2ms | 3428kb | C++20 | 1.1kb | 2023-05-11 20:00:03 | 2023-05-11 20:00:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mx = 112;
typedef pair<int, int> ii;
vector<int> adj[mx];
int A[mx], B[mx], n;
bool check (int hp) {
vector<bool> inq(mx, 0);
priority_queue<ii> pq;
pq.emplace(0, 0);
while (!pq.empty()) {
auto[w, v] = pq.top();
inq[v] = true;
hp += w;
pq.pop();
for (int i = 0; i < n; i++) {
if (inq[i]) {
for (auto u : adj[i]) {
if (!inq[u] && A[u] <= hp) {
pq.emplace(B[u] - A[u], u);
}
}
}
}
}
for (int i = 0; i < n; i++) {
if (!inq[i]) return 0;
}
return 1;
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int m;
cin >> n >> m;
for (int i = 1; i < n; i++) {
cin >> A[i] >> B[i];
}
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
a--, b--;
adj[a].emplace_back(b);
}
int lo = 0, hi = 1e18;
while (hi - lo > 1) {
int mid = (lo+hi)/2;
if (check(mid)) hi = mid;
else lo = mid;
}
if (hi < lo) swap(lo, hi);
if (check(lo)) cout << lo << endl;
else cout << hi << endl;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3416kb
input:
4 4 4 2 5 3 2 6 1 2 1 3 2 4 3 4
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3428kb
input:
15 14 254040392438309 117083115436273 500005748229691 557255157630172 821034233718230 865199673774998 659892147898798 987564141425694 81172575487567 811635577877255 751768357864605 341103322647288 454926350150218 140191090713900 921608121471585 659295670987251 223751724062143 505619245326640 8907765...
output:
900742101319785
result:
wrong answer 1st numbers differ - expected: '1665396301509143', found: '900742101319785'