답안 #525901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525901 2022-02-13T06:28:39 Z shark25361 Stove (JOI18_stove) C++14
100 / 100
22 ms 2372 KB
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;

#define FIO ios_base::sync_with_stdio(false);cin.tie(0);
#define ll long long
#define for_t ll T;cin>>T;while(T--)
#define endl "\n"
#define F(a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define pb push_back

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,std::less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
*/

void sol()
{
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    sort(a,a + n);
    vector<ll> gaps;
    for(int i = 1;i < n;i++)
    {
        gaps.pb(a[i] - a[i - 1] - 1);
    }
    sort(all(gaps));
    ll time = n;
    for(int i = 0;i < n - k;i++)
    {
        time += gaps[i];
    }
    cout << time << endl;
}

int main()
{
    //freopen("milkvisits.in", "r", stdin);
    //freopen("milkvisits.out", "w", stdout);
    //iota(all(link),0);
    FIO
    sol();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 18 ms 2232 KB Output is correct
17 Correct 18 ms 2244 KB Output is correct
18 Correct 18 ms 2244 KB Output is correct
19 Correct 18 ms 2252 KB Output is correct
20 Correct 18 ms 2292 KB Output is correct
21 Correct 18 ms 2224 KB Output is correct
22 Correct 22 ms 2372 KB Output is correct
23 Correct 18 ms 2304 KB Output is correct
24 Correct 18 ms 2244 KB Output is correct