63922023-11-26 19:24:34horvathabelMúzeumi őrökcpp17Wrong answer 22/40133ms63776 KiB
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
struct mor{
    ll ar;
    ll k;
    ll v;
    ll i;
};
struct p{
    ll penz;
    ll v;
    vector<ll>mego;
};
struct compar{
    bool operator()(mor a, mor b){
        return (a.ar>b.ar);
    }
};
int main()
{
    ll n,k,v;
    cin>>n>>k>>v;
    vector<vector<mor>> ve;

    ve.resize(v+1,vector<mor>());
    priority_queue<mor,vector<mor>, compar> q;
    for (ll i=0; i<n;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        ve[max(a,k)].push_back({c,a,b,i});
    }
    vector<p> dp;
    dp.resize(v+1);
    dp[k-1]={0,0,{}};
    for (ll i=k;i<=v;i++){
        for (mor x:ve[i]) q.push(x);
        if (dp[i-1].v>=i) dp[i]=dp[i-1];
        else{
            while (!q.empty() && q.top().v<i){
                q.pop();

            }
            if (q.empty()){
                cout<<-1;
                return 0;
            }
            mor most=q.top();
            dp[i]=dp[most.k-1];
            dp[i].penz+=most.ar;
            dp[i].v=most.v;
            dp[i].mego.push_back(most.i);
        }
    }
    cout<<dp[v].penz<<"\n"<<dp[v].mego.size()<<" ";
    for (ll z:dp[v].mego) cout<<z+1<<" ";
}
SubtaskSumTestVerdictTimeMemory
base22/40
1Accepted0/03ms1812 KiB
2Wrong answer0/037ms63664 KiB
3Accepted1/13ms2368 KiB
4Accepted3/33ms2592 KiB
5Accepted2/23ms2676 KiB
6Accepted2/23ms2968 KiB
7Accepted2/23ms3060 KiB
8Accepted2/23ms3156 KiB
9Accepted2/23ms3368 KiB
10Runtime error0/2133ms63776 KiB
11Runtime error0/2130ms63672 KiB
12Wrong answer0/23ms3752 KiB
13Wrong answer0/28ms6784 KiB
14Runtime error0/337ms63472 KiB
15Runtime error0/339ms63412 KiB
16Runtime error0/2130ms63404 KiB
17Runtime error0/2130ms63140 KiB
18Accepted2/23ms3800 KiB
19Accepted2/23ms3800 KiB
20Accepted2/23ms3804 KiB
21Accepted2/23ms3812 KiB