Submission #331083

#TimeUsernameProblemLanguageResultExecution timeMemory
331083ItzMeOwwwStove (JOI18_stove)C++14
100 / 100
158 ms1896 KiB
#include <bits/stdc++.h>
using namespace std;
priority_queue<int>pq;
int main(){
    int n,t;
    long long ans = 0;
    int bx,x;
    scanf(" %d %d",&n,&t);
    scanf(" %d",&bx);
    for(int i = 2;i<=n;i++){
        scanf(" %d",&x);
        pq.push(x - bx);
        bx = x;
    }
    long long add = 0;
    t--;
    ans++;
    while(t-- && !pq.empty()){
        ans++;
        pq.pop();
    }
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    cout << ans;
}

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:15:15: warning: unused variable 'add' [-Wunused-variable]
   15 |     long long add = 0;
      |               ^~~
stove.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf(" %d %d",&n,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~
stove.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf(" %d",&bx);
      |     ~~~~~^~~~~~~~~~~
stove.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |         scanf(" %d",&x);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...