제출 #1357612

#제출 시각아이디문제언어결과실행 시간메모리
1357612KALARRYJOI Tour 2 (JOI26_joitour)C++20
0 / 100
5 ms16884 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);
    assert(M <= 4000);
    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;
        for(int x = 1 ; x <= s ; x++)
            dp[x][0] += c;
        int pos = 0; //pos is the maximum position for which you decide to 
        for(int j = 1 ; j <= K ; j++)
        {
            while(pos < s && dp[pos+1][j] + c > dp[t][j-1])
                pos++;
            for(int x = 1 ; x <= pos ; x++)
                dp[x][j] = dp[t][j-1];
            for(int x = pos+1 ; x <= s ; x++)
                dp[x][j] += c;
            // dp[x][j] = min(dp[x][j] + c,dp[t][j-1]);
        }
    }
    printf("%lld\n",dp[1][K]);
    return 0;
}

컴파일 시 표준 에러 (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:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         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...
#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...