#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())
struct gujo
{
ll T, L, R, C;
bool operator < (const gujo &xx) const
{
return L < xx.L;
}
};
ll n, m;
gujo a[100010];
ll dp[100010];
ll ans = INF;
int main(void)
{
fastio
cin >> n >> m;
for(ll i = 1 ; i <= m ; i++)
{
cin >> a[i].T >> a[i].L >> a[i].R >> a[i].C;
dp[i] = INF;
}
sort(a + 1, a + 1 + m);
for(ll i = 1 ; i <= m ; i++)
{
if(a[i].L == 1)
dp[i] = a[i].C;
for(ll j = 1 ; j < i ; j++)
{
if(a[i].L <= a[j].R - abs(a[i].T - a[j].T) + 1)
dp[i] = min(dp[i], dp[j] + a[i].C);
}
}
for(ll i = 1 ; i <= m ; i++)
{
if(a[i].R == n)
ans = min(ans, dp[i]);
}
if(ans == INF)
cout << -1;
else
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3050 ms |
7408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3050 ms |
7408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |