QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#631060 | #3563. Treatment Project | Dimash | 0 | 0ms | 3668kb | C++23 | 1.2kb | 2024-10-11 21:44:38 | 2024-10-11 21:44:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 12, MOD = (int)1e9 + 7;
const ll inf = 1e18;
ll res = inf, dp[N];
int n, m;
vector<array<int, 4>> a;
bool cmp(array<int, 4> x, array<int, 4> y) {
return make_pair(x[1], x[2]) < make_pair(y[1], y[2]);
}
void test() {
cin >> n >> m;
a.resize(m);
for(int i = 0; i < m; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
}
sort(a.begin(), a.end(), cmp);
for(int i = 0; i < m; i++) {
dp[i] = inf;
}
for(int i = 0; i < m && a[i][1] == 1; i++) {
dp[i] = 0;
}
for(int i = 0; i < m; i++) {
dp[i] += a[i][3];
if(a[i][2] == n) {
res = min(res, dp[i]);
}
for(int j = i + 1; j < m; j++) {
ll inter = a[i][2] - a[j][1] + 1, val = abs(a[i][0] - a[j][0]);
if(inter >= val) {
dp[j] = min(dp[j], dp[i]);
}
}
}
if(res == inf) {
res = -1;
}
cout << res << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
test();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
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: 3580kb
input:
1 1 1000000000 1 1 1000000000
output:
1000000000
result:
ok single line: '1000000000'
Test #20:
score: 0
Wrong Answer
time: 0ms
memory: 3668kb
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%