제출 #1003371

#제출 시각아이디문제언어결과실행 시간메모리
1003371UnforgettableplTreatment Project (JOI20_treatment)C++17
35 / 100
3051 ms9812 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

struct plan{
    int t,l,r,c;
    plan(int t,int l,int r,int c):t(t),l(l-1),r(r+1),c(c){}
    bool operator<(const plan& other)const{
        return c<other.c;
    }
};

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;
    list<plan> plans;
    priority_queue<pair<int,plan>> q;
    for(int i=1;i<=m;i++){
        int t,l,r,c;cin>>t>>l>>r>>c;
        if(l==1) q.emplace(-c,plan(t,l,r,c));
        else plans.emplace_back(t,l,r,c);
    }
    while(!q.empty()){
        auto [dist,curr] = q.top();q.pop();
        if(curr.r==n+1){
            cout << -dist << '\n';
            return 0;
        }
        auto iter = plans.begin();
        while(iter!=plans.end()){
            if(iter->t+iter->l<curr.r+curr.t and curr.t-curr.r<iter->t-iter->l){
                q.emplace(dist-iter->c,*iter);
                iter=plans.erase(iter);
            } else iter++;
        }
    }
    cout << "-1\n";
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...