Submission #1357464

#TimeUsernameProblemLanguageResultExecution timeMemory
1357464KALARRYTeleporter 2 (JOI26_teleporter)C++20
0 / 100
1 ms2372 KiB
//chockolateman

#include<bits/stdc++.h>

using namespace std;

int N,M,K;
pair<pair<int,int>,int> seg[100005];
long long dp[4005][4005];

int main()
{
    scanf("%d%d%d",&N,&M,&K);
    for(int s,t,c,i = 1 ; i <= M ; i++)
    {
        scanf("%d%d%d",&s,&t,&c);
        seg[i] = {{t,s},c};
    }
    sort(seg+1,seg+M+1);
    for(int s,t,c,i = M ; i >= 1 ; i--)
    {
        t = seg[i].first.first;
        s = seg[i].first.second;
        c = seg[i].second;
        int nxt = M+1;
        for(int x = i+1 ; x <= M ; x++)
            if(seg[x].first.second >= t)
            {
                nxt = x;
                break;
            }
        dp[i][0] = dp[i+1][0] + c;
        for(int j = 1 ; j <= K ; j++)
            dp[i][j] = min(dp[i+1][j] + c,dp[nxt][j-1]);
    }
    printf("%lld\n",dp[1][K]);
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d%d%d",&N,&M,&K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d%d%d",&s,&t,&c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...