답안 #571695

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
571695 2022-06-02T14:39:29 Z Quan2003 Stove (JOI18_stove) C++17
100 / 100
51 ms 2892 KB
#include <bits/stdc++.h>
#include <iostream>
#include<queue>
#include<vector>
#include<utility>
using namespace std;
typedef long long ll;
const int sz=101;
const int sz1=2e5+1;
int n,x,k,i,j,w,m;
ll res=1e18;
ll ans=0;
int movex[4]={0,0,1,-1};
int movey[4]={-1,1,0,0};
ll c[sz1];
vector<ll>adj[sz];
ll d[sz1];
vector<array<ll,2>>a;
ll dp[sz][sz];
int main(){
   cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>d[i];
    } for(int i=2;i<=n;i++){
        c[i-1]=d[i]-d[i-1];
    } 
      sort(c+1,c+n); ans=k;
      for(int i=1;i<=n-k;i++){
          ans+=c[i];
      } cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 43 ms 2764 KB Output is correct
17 Correct 44 ms 2764 KB Output is correct
18 Correct 51 ms 2824 KB Output is correct
19 Correct 43 ms 2764 KB Output is correct
20 Correct 43 ms 2716 KB Output is correct
21 Correct 47 ms 2704 KB Output is correct
22 Correct 45 ms 2800 KB Output is correct
23 Correct 44 ms 2720 KB Output is correct
24 Correct 45 ms 2892 KB Output is correct