답안 #198527

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198527 2020-01-26T13:44:19 Z killB0x Stove (JOI18_stove) C++14
100 / 100
81 ms 6904 KB
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> dl;
typedef vector<ii> vii;
typedef vector<dl> vdll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define in insert
#define bs binary_search
#define rc(s) return cout << s,0
const ll mod=1e9+7;
const int N=100005;
#define M_PI 3.14159265358979323846
#define INF LLONG_MAX
#define sz(x) ((int)(x.size()))
#define int ll
#define endl '\n'
#define map unordered_map
/*----------------------------*/
int a[N];
/*----------------------------*/
int32_t main() {
    //freopen("sol.in","r",stdin);
    //freopen("sol.out","w",stdout);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    multiset<int> s;
    for(int i=2;i<=n;i++)s.in(a[i]-a[i-1]-1);
    int ans=n;
    int u=n-k;
    for(auto it=s.begin();it!=s.end();it++)
    {
        if(u==0)break;
        ans+=*it;
        u--;
    }
    rc(ans);
    //THIS IS IS THE END    
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 7 ms 504 KB Output is correct
12 Correct 6 ms 504 KB Output is correct
13 Correct 6 ms 504 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 7 ms 504 KB Output is correct
12 Correct 6 ms 504 KB Output is correct
13 Correct 6 ms 504 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 73 ms 5760 KB Output is correct
17 Correct 67 ms 6776 KB Output is correct
18 Correct 81 ms 6776 KB Output is correct
19 Correct 66 ms 6776 KB Output is correct
20 Correct 72 ms 6776 KB Output is correct
21 Correct 61 ms 6776 KB Output is correct
22 Correct 67 ms 6904 KB Output is correct
23 Correct 64 ms 6776 KB Output is correct
24 Correct 65 ms 6776 KB Output is correct