Submission #293049

# Submission time Handle Problem Language Result Execution time Memory
293049 2020-09-07T15:49:26 Z dolijan Stove (JOI18_stove) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    vector<ll> diff;
    for(int i=1;i<n;i++) diff.push_back(a[i]-a[i-1]);
    sort(diff.begin(),diff.end());
    ll kolko=0;
    k--;
    for(int i=diff.size()-1;i>=diff.size()-k;i--) kolko+=diff[i];
    kolko=((a[n-1]-a[0])-kolko);
    kolko+=(k+1);
    cout<<kolko<<endl;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:15:30: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   15 |     for(int i=diff.size()-1;i>=diff.size()-k;i--) kolko+=diff[i];
      |                             ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Runtime error 1 ms 384 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Runtime error 1 ms 384 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Runtime error 1 ms 384 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -