Submission #318647

# Submission time Handle Problem Language Result Execution time Memory
318647 2020-11-02T18:07:15 Z urosk Stove (JOI18_stove) C++14
0 / 100
1 ms 364 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;
    sort(v.begin(),v.end(),cmp);
    int ans = a[0]-a[n-1]+1;
    for(int i = 0;i<n-1;i++){
        v.pb({a[i+1]+1,a[i]});
    }
    //for(auto &it : v) cout<<it.fi<< " "<<it.sc<<"\n";
    for(int i=0;i<k-1;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 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -