| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1285946 | hainam2k9 | Treatment Project (JOI20_treatment) | C++20 | 3090 ms | 2580 KiB |
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "";
struct Project{
int t,l,r,cost;
}a[MAXN];
int n,m;
ll dp[MAXN],rs=1e18;
priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;
bool check(int i, int j){
if(a[i].t>=a[j].t) return a[i].r+1>=a[j].l+a[i].t-a[j].t;
return a[i].r+a[i].t-a[j].t+1>=a[j].l;
}
int main()
{
tt;
if(fopen((NAME + ".INP").c_str(), "r")) fo;
memset(dp,0x3f,sizeof(dp));
cin >> n >> m;
for(int i = 1; i<=m; ++i){
cin >> a[i].t >> a[i].l >> a[i].r >> a[i].cost;
if(a[i].l==1) dp[i]=a[i].cost, pq.ins(a[i].cost,i);
}
while(!pq.empty()){
pair<ll,int> top=pq.top();
pq.pop();
if(top.fi>dp[top.se]) continue;
if(a[top.se].r==n) rs=min(rs,top.fi);
for(int i = 1; i<=m; ++i)
if(check(top.se,i)&&dp[i]>top.fi+a[i].cost) dp[i]=top.fi+a[i].cost, pq.ins(dp[i],i);
}
cout << (rs>=1e18 ? -1 : rs);
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
