Submission #810855

# Submission time Handle Problem Language Result Execution time Memory
810855 2023-08-06T16:47:15 Z mdacode Stove (JOI18_stove) C++14
0 / 100
1 ms 212 KB
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include<algorithm>
using namespace std;


int main(){
   long long nbi,k;
   cin >> nbi >> k;
   vector<long long>dif;
   long long firv,fir,sec,tot=0;
   cin >> fir;
   firv=fir;
   for(long long i=0;i<nbi-1;i++){
       cin >> sec;
       dif.push_back(sec-(fir+1));
       fir=sec;
   }
   sort(dif.begin(),dif.end());
   long long res=(sec+1)-firv;
   for(long long j=nbi-2;j>=nbi-k;j--){
       res-=dif[j];
   }
   cout << res;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:14:27: warning: unused variable 'tot' [-Wunused-variable]
   14 |    long long firv,fir,sec,tot=0;
      |                           ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -