| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1357612 | KALARRY | JOI Tour 2 (JOI26_joitour) | C++20 | 5 ms | 16884 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;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
