Submission #415858

# Submission time Handle Problem Language Result Execution time Memory
415858 2021-06-01T15:50:59 Z Anish_Bashyal Stove (JOI18_stove) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>

using namespace std;


int main() {
  int n,k;
  cin >> n >> k;
  multiset<int,greater<int>> s;
  int t[n];
  for(int i=0;i<n;i++){
    cin >> t[i];
  }
  k--;
  int ans=t[n-1];
  for(int i=0;i<n-1;i++) {
    int dt=t[i+1]-t[i]-1;
    //cout << "dt " <<dt << "\n";
    s.insert(t[i+1]-t[i]-1);
  }
  for(auto i:s){
    if(k==0) break;
    ans-=i;
    k--;
  }
  cout << ans<<"\n";
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:17:9: warning: unused variable 'dt' [-Wunused-variable]
   17 |     int dt=t[i+1]-t[i]-1;
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -