Submission #318649

# Submission time Handle Problem Language Result Execution time Memory
318649 2020-11-02T18:21:07 Z urosk Stove (JOI18_stove) C++14
100 / 100
62 ms 2908 KB
#include <bits/stdc++.h>
#include <chrono>
#define unint unsigned int
#define sint signed int
#define shint short int
#define usint unsigned short int
#define lint long int
#define ulint unsigned long int
#define ll long long
#define ull unsigned long long
#define ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf 1e15
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
using namespace std;
using namespace std::chrono;
/*auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
vector<char> abecede = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
cout << "Time taken by function: " << duration.count() << " microseconds" << endl;*/
void solve(){


}
#define maxn 100005
int a[maxn];
bool cmp(pair<int,int> a,pair<int,int> b){
    return a.fi-a.sc>b.fi-b.sc;
}
int main(){
    int n,k;
    cin >> n>>k;
    for(int i = 0;i<n;i++) cin >> a[i];
    sort(a,a+n,greater<int>());
    vector<pair<int,int> > v;
    int ans = n;
    for(int i = 0;i<n-1;i++){
        v.pb({a[i+1]+1,a[i]});
    }
    sort(v.begin(),v.end(),cmp);
    //for(auto &it : v) cout<<it.fi<< " "<<it.sc<<"\n";
    for(int i=0;i<n-k;i++){
        ans+=v[i].sc-v[i].fi;
    }
    cout<<ans;
}

Compilation message

stove.cpp:11:9: warning: ISO C++11 requires whitespace after the macro name
   11 | #define ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
      |         ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 56 ms 2908 KB Output is correct
17 Correct 61 ms 2908 KB Output is correct
18 Correct 62 ms 2908 KB Output is correct
19 Correct 56 ms 2908 KB Output is correct
20 Correct 56 ms 2908 KB Output is correct
21 Correct 57 ms 2908 KB Output is correct
22 Correct 56 ms 2908 KB Output is correct
23 Correct 57 ms 2908 KB Output is correct
24 Correct 57 ms 2908 KB Output is correct