Submission #1125587

#TimeUsernameProblemLanguageResultExecution timeMemory
1125587phoopStove (JOI18_stove)C++20
0 / 100
0 ms320 KiB
#include <iostream>
#include <queue>
using namespace std;
priority_queue<int> pq;
 
int main()
{
    int N,K,past,now; scanf("%d %d %d",&N,&K,&now);
    for(int i=1;i<N;i++)
    {
        past=now;
        scanf("%d",&now);
        pq.push(-(now-past-1));
    }
    int ans=N;
    for(int i=0;i<N-K;i++)
    {
        ans-=pq.top();
        pq.pop();
    }
    return printf("%d\n",ans);
}

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:8:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     int N,K,past,now; scanf("%d %d %d",&N,&K,&now);
      |                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d",&now);
      |         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...