# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
52394 | 2018-06-25T18:23:14 Z | updown1 | Stove (JOI18_stove) | C++17 | 37 ms | 2528 KB |
/* greedily remove gaps between people */ #include <bits/stdc++.h> using namespace std; typedef long long ll; #define For(i, a, b) for(int i=a; i<b; i++) #define ffi For(i, 0, N) #define ffj For(j, 0, M) #define ffa ffi ffj #define s <<" "<< #define w cout #define e "\n" #define pb push_back #define mp make_pair #define a first #define b second #define int ll const int MAXN=100000, INF=2000000000000000000; ///500,000,000 int N, K, inp[MAXN], out; priority_queue<int> gap; main() { //ifstream cin("test.in"); ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> K; ffi cin >> inp[i]; sort(inp, inp+N); For (i, 1, N+1) gap.push(inp[i] - inp[i-1]-1); out = inp[N-1]-inp[0]+1; For (i, 1, K) { int x = gap.top(); gap.pop(); out -= x; //w<< x<<e; } w<< out<<e; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Correct | 2 ms | 484 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 3 ms | 516 KB | Output is correct |
6 | Correct | 2 ms | 568 KB | Output is correct |
7 | Correct | 2 ms | 568 KB | Output is correct |
8 | Correct | 2 ms | 568 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Correct | 2 ms | 484 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 3 ms | 516 KB | Output is correct |
6 | Correct | 2 ms | 568 KB | Output is correct |
7 | Correct | 2 ms | 568 KB | Output is correct |
8 | Correct | 2 ms | 568 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
10 | Correct | 2 ms | 592 KB | Output is correct |
11 | Correct | 3 ms | 592 KB | Output is correct |
12 | Correct | 2 ms | 592 KB | Output is correct |
13 | Correct | 4 ms | 592 KB | Output is correct |
14 | Correct | 3 ms | 592 KB | Output is correct |
15 | Correct | 3 ms | 616 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Correct | 2 ms | 484 KB | Output is correct |
4 | Correct | 2 ms | 484 KB | Output is correct |
5 | Correct | 3 ms | 516 KB | Output is correct |
6 | Correct | 2 ms | 568 KB | Output is correct |
7 | Correct | 2 ms | 568 KB | Output is correct |
8 | Correct | 2 ms | 568 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
10 | Correct | 2 ms | 592 KB | Output is correct |
11 | Correct | 3 ms | 592 KB | Output is correct |
12 | Correct | 2 ms | 592 KB | Output is correct |
13 | Correct | 4 ms | 592 KB | Output is correct |
14 | Correct | 3 ms | 592 KB | Output is correct |
15 | Correct | 3 ms | 616 KB | Output is correct |
16 | Correct | 36 ms | 2432 KB | Output is correct |
17 | Correct | 20 ms | 2508 KB | Output is correct |
18 | Correct | 20 ms | 2508 KB | Output is correct |
19 | Correct | 21 ms | 2508 KB | Output is correct |
20 | Correct | 27 ms | 2528 KB | Output is correct |
21 | Correct | 32 ms | 2528 KB | Output is correct |
22 | Correct | 32 ms | 2528 KB | Output is correct |
23 | Correct | 32 ms | 2528 KB | Output is correct |
24 | Correct | 37 ms | 2528 KB | Output is correct |