| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1358223 | KALARRY | Ski 2 (JOI24_ski2) | C++20 | 0 ms | 344 KiB |
//chockolateman
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
int N,K,h[305],c[305];
pair<long long,long long> temp[305],cur_val[305];
int main()
{
scanf("%d%d",&N,&K);
for(int i = 1 ; i <= N ; i++)
{
scanf("%d%d",&h[i],&c[i]);
temp[i] = {h[i],c[i]};
}
sort(temp+1,temp+N+1);
long long ans = INF;
long long adding = 0;
for(int i = 2 ; i <= N ; i++)
if(temp[i].first == temp[1].first)
{
temp[i].first++;
adding += K;
}
for(int l = N ; l >= 2 ; l--) //untill which one you get for free
{
long long cur_ans = adding + (l-2)*temp[1].second;
for(int i = 1 ; i <= N ; i++)
cur_val[i] = temp[i];
for(int x = l ; x <= N ; x++)
{
cur_ans += max(0ll,cur_val[1+(x-l)].first + 1 - temp[x].first)*K;
cur_val[x].first = max(cur_val[1+(x-l)].first + 1,temp[x].first);
}
ans = min(ans,cur_ans);
}
printf("%lld\n",ans);
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... | ||||
