Submission #1358223

#TimeUsernameProblemLanguageResultExecution timeMemory
1358223KALARRYSki 2 (JOI24_ski2)C++20
12 / 100
0 ms344 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)

Main.cpp: In function 'int main()':
Main.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d%d",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d%d",&h[i],&c[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
#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...