Submission #52394

# Submission time Handle Problem Language Result Execution time Memory
52394 2018-06-25T18:23:14 Z updown1 Stove (JOI18_stove) C++17
100 / 100
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

stove.cpp:24:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
stove.cpp: In function 'int main()':
stove.cpp:7:22: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 #define For(i, a, b) for(int i=a; i<b; i++)
                      ^
stove.cpp:8:13: note: in expansion of macro 'For'
 #define ffi For(i, 0, N)
             ^~~
stove.cpp:28:5: note: in expansion of macro 'ffi'
     ffi cin >> inp[i]; sort(inp, inp+N);
     ^~~
stove.cpp:28:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     ffi cin >> inp[i]; sort(inp, inp+N);
                        ^~~~
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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