QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#108101 | #3563. Treatment Project | bashkort# | 0 | 0ms | 3568kb | C++20 | 1.1kb | 2023-05-23 16:18:57 | 2024-05-31 13:40:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Segment {
int t, l, r, w;
};
constexpr ll inf = 3e18;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<Segment> s(m);
for (auto &[t, l, r, w] : s) {
cin >> t >> l >> r >> w;
}
sort(s.begin(), s.end(), [&](const auto &x, const auto &y) {
return pair{x.r, x.t} < pair{y.r, y.t};
});
vector<ll> dp(m);
for (int i = 0; i < m; ++i) {
if (s[i].l == 1) {
dp[i] = s[i].w;
continue;
}
dp[i] = inf;
for (int j = 0; j < i; ++j) {
if (s[j].r - s[i].l + 1 >= abs(s[i].t - s[j].t)) {
dp[i] = min(dp[i], dp[j] + s[i].w);
}
}
}
ll ans = inf;
for (int i = 0; i < m; ++i) {
if (s[i].r == n) {
ans = min(ans, dp[i]);
}
}
if (ans == inf) {
cout << "-1\n";
} else {
cout << ans << '\n';
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
1000000000 100000 1 811370001 811380000 1000000000 1 413190001 413200000 1000000000 1 462480001 462490000 1000000000 1 384860001 384870000 1000000000 1 543220001 543230000 1000000000 1 766300001 766310000 1000000000 1 348890001 348900000 1000000000 1 996350001 996360000 1000000000 1 302700001 302710...
output:
result:
Subtask #2:
score: 0
Wrong Answer
Test #19:
score: 5
Accepted
time: 0ms
memory: 3568kb
input:
1 1 1000000000 1 1 1000000000
output:
1000000000
result:
ok single line: '1000000000'
Test #20:
score: 0
Wrong Answer
time: 0ms
memory: 3568kb
input:
1000000000 16 6 2 2 1 4 999999997 999999999 4 2 999999997 1000000000 2 3 1 4 3 3 999999997 1000000000 3 5 999999998 999999999 3 6 999999999 999999999 1 2 1 4 2 6 3 999999998 1 999999987 1 1000000000 10 999999986 1 1000000000 10 999999985 1 1000000000 10 4 2 4 4 5 2 3 3 1 999999997 1000000000 1 1 1 4 1
output:
10
result:
wrong answer 1st lines differ - expected: '9', found: '10'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%