제출 #1358207

#제출 시각아이디문제언어결과실행 시간메모리
1358207KALARRYSki 2 (JOI24_ski2)C++20
0 / 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;
    if(N > 1)
    {
        if(temp[1].first == temp[2].first)
        {
            temp[1].first--;
            ans += K;
        }
        long long min_found = temp[1].second;
        int l = 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);
            }
            ans += min_found;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

컴파일 시 표준 에러 (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...