Submission #1358213

#TimeUsernameProblemLanguageResultExecution timeMemory
1358213KALARRYSki 2 (JOI24_ski2)C++20
5 / 100
0 ms344 KiB
//chockolateman

#include<bits/stdc++.h>

using namespace std;

int N,K,h[305],c[305];
pair<long long,long long> temp[305];

int main()
{
    scanf("%d%d",&N,&K);

    h[0] = 305;
    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 = 0;
    for(int i = 2 ; i <= N ; i++)
    {
        if(temp[i].first == temp[1].first)
        {
            ans += K;
            temp[i].first++;
        }
    }
    long long min_found = temp[1].second;
    int l = 1;
    int cnt_free = 1;
    for(int r = 2 ; r <= N ; r++)
    {
        while(temp[l+1].first < temp[r].first)
        {
            l++;
            min_found = min(min_found,temp[l].second);
            cnt_free++;
        }
        if(cnt_free)
            cnt_free--;
        else
            ans += min_found;
    }
    printf("%lld\n",ans);
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d",&N,&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",&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...