답안 #461349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
461349 2021-08-09T22:41:25 Z ZaZo_ Stove (JOI18_stove) C++14
100 / 100
57 ms 2236 KB
//Sorry but iam targeting IOI :))
//NEVER LOSE HOPE
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define endl "\n"
#define ceil(a,b)   (a+(b-1))/b
#define all(v) v.begin(),v.end()
#define int long long int
#define Hidden ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=3e4+10,mod = 1e9+7;
int32_t main(){
  int n , k ;
  cin >> n >> k ;
  vector<int>guests(n),diff;
  for(int i = 0 ; i < n ; i ++)
  {
    cin>>guests[i];
  }
  long long ans=n;
  for(int i = 1 ; i < n ; i ++)
  {
    diff.push_back(guests[i]-guests[i-1]-1);
    ans+=diff.back();
  }
  sort(all(diff));
  //cout<<ans<<endl;

  for(int i = diff.size()-1 ; i>=0 && k>1 ; i-- , k--)
  {
    ans-=diff[i];
  }
  cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 53 ms 2224 KB Output is correct
17 Correct 50 ms 2224 KB Output is correct
18 Correct 50 ms 2108 KB Output is correct
19 Correct 51 ms 2208 KB Output is correct
20 Correct 50 ms 2224 KB Output is correct
21 Correct 50 ms 2220 KB Output is correct
22 Correct 50 ms 2108 KB Output is correct
23 Correct 57 ms 2236 KB Output is correct
24 Correct 51 ms 2216 KB Output is correct