Submission #1357473

#TimeUsernameProblemLanguageResultExecution timeMemory
1357473KALARRYTeleporter 2 (JOI26_teleporter)C++20
0 / 100
0 ms344 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;
        dp[s][0] += c;
        for(int j = 1 ; j <= K ; j++)
            dp[s][j] = min(dp[s][j] + c,dp[t][j-1]);
        for(int x = s-1 ; x >= 1 ; x--)
            for(int j = 0 ; j <= K ; j++)
                dp[x][j] = max(dp[x][j],dp[x+1][j]);
    }
    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...