답안 #1103841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103841 2024-10-22T02:05:49 Z Alex0x0 Stove (JOI18_stove) C++17
100 / 100
21 ms 3360 KB
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fore(i,a,b) for(lli i = (a), abcdxd = (b); i < abcdxd; i++)
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define sz(v) lli((v).size())
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using namespace std;
typedef long long lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef long double ld;
#define deb(x) cout << #x << ": " << x << ENDL;

int main(){ _
  lli n, k; cin >> n >> k;
  vi v;
  lli ans = 1ll;
  {
    vi b(n); for (auto & i : b) cin >> i; sort(all(b));
    fore(i,1,n){
      if (b[i] == b[i - 1]) continue;
      ans++;
      v.pb(b[i] - (b[i - 1] + 1ll));
    }
  }
  sort(all(v));
  fore(i,0,max(0ll, sz(v) - k + 1ll)) ans += v[i];
  cout << ans << ENDL;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 17 ms 3280 KB Output is correct
17 Correct 21 ms 3280 KB Output is correct
18 Correct 18 ms 3280 KB Output is correct
19 Correct 17 ms 3280 KB Output is correct
20 Correct 17 ms 3284 KB Output is correct
21 Correct 16 ms 3280 KB Output is correct
22 Correct 17 ms 3360 KB Output is correct
23 Correct 17 ms 3240 KB Output is correct
24 Correct 19 ms 3280 KB Output is correct