QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#571554 | #9353. Interesting Permutation | real_sigma_team# | WA | 0ms | 3544kb | C++17 | 1.9kb | 2024-09-18 00:29:39 | 2024-09-18 00:29:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int tests;
cin >> tests;
while (tests--) {
int n;
cin >> n;
int m1, m2;
cin >> m1 >> m2;
vector<tuple<int, int, int>> q1(m1), q2(m2);
for (auto& [l, r, x] : q1) {
cin >> l >> r >> x;
--l;
}
for (auto& [l, r, x] : q2) {
cin >> r >> l >> x;
--r;
}
int L = 0, R = n;
while (L != R) {
int M = (L + R) / 2;
vector<int> dist(n + 1, -1e9);
dist[0] = 0;
bool upd = false;
for (int iter = 0; iter <= n + 1; ++iter) {
upd = false;
for (int i = 0; i < n; ++i) {
if (dist[i + 1] < dist[i]) {
dist[i + 1] = dist[i];
upd = true;
}
}
for (int i = 0; i < n; ++i) {
if (dist[i] < dist[i + 1] - 1) {
dist[i] = dist[i + 1] - 1;
upd = true;
}
}
for (auto [l, r, x] : q1) {
if (dist[r] < dist[l] + x) {
dist[r] = dist[l] + x;
upd = true;
}
}
for (auto [l, r, x] : q2) {
x -= M;
if (dist[r] < dist[l] + x) {
dist[r] = dist[l] + x;
upd = true;
}
}
}
if (dist[n] > M || upd) {
L = M + 1;
} else {
R = M;
}
}
cout << R << '\n';
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3544kb
input:
3 3 0 2 2 3 0 1 2 3 0 2 3
output:
3 0 0
result:
wrong answer 1st lines differ - expected: '2', found: '3'