QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#464191 | #3563. Treatment Project | Rafi22# | 0 | 1ms | 5616kb | C++20 | 1.5kb | 2024-07-05 21:58:25 | 2024-07-05 21:58:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif
#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
const int N=100007;
int t[N],l[N],r[N];
ll DP[N],c[N];
bool odw[N];
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,m;
cin>>n>>m;
FOR(i,1,m)
{
cin>>t[i]>>l[i]>>r[i]>>c[i];
DP[i]=infl;
if(l[i]==1) DP[i]=c[i];
}
ll ans=infl;
FOR(k,1,n)
{
ll mn=infl+1;
int i;
FOR(j,1,m)
{
if(!odw[j]&&DP[j]<mn)
{
mn=DP[j];
i=j;
}
}
odw[i]=1;
debug(i,DP[i]);
FOR(j,1,m)
{
if(t[j]<=t[i])
{
if(r[i]-(t[i]-t[j])>=l[j]-1) DP[j]=min(DP[j],DP[i]+c[j]);
}
else
{
if(r[i]-(t[j]-t[i])>=l[j]-1) DP[j]=min(DP[j],DP[i]+c[j]);
}
}
if(r[i]==n) ans=min(ans,DP[i]);
}
if(ans==infl) cout<<-1<<endl;
else cout<<ans<<endl;
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
Time Limit Exceeded
Test #19:
score: 5
Accepted
time: 1ms
memory: 5616kb
input:
1 1 1000000000 1 1 1000000000
output:
1000000000
result:
ok single line: '1000000000'
Test #20:
score: -5
Time Limit Exceeded
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:
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%