Submission #49012

# Submission time Handle Problem Language Result Execution time Memory
49012 2018-05-21T07:40:05 Z WLZ Stove (JOI18_stove) C++17
100 / 100
48 ms 10692 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int INF = 1e9;
const int MAXN = 1e5 + 5;
const ll LINF = 1e18;
const double pi = acos(-1);
const double EPS = 1e-9;
template <class T> using MinPQ = priority_queue<T, vector<T>, greater<T>>;
template <class T> using MaxPQ = priority_queue<T>;



int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> a(n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    int ans = n;
    MinPQ<int> pq;
    for (int i = 1; i < n; i++) pq.push(a[i] - a[i - 1] - 1);
    for (int i = 0; i < n - k; i++) {
        ans += pq.top();
        pq.pop();
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:21:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < n; i++) scanf("%d", &a[i]);
                                 ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 436 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 436 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 4 ms 764 KB Output is correct
11 Correct 4 ms 764 KB Output is correct
12 Correct 4 ms 764 KB Output is correct
13 Correct 3 ms 788 KB Output is correct
14 Correct 5 ms 836 KB Output is correct
15 Correct 4 ms 1040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 436 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 4 ms 764 KB Output is correct
11 Correct 4 ms 764 KB Output is correct
12 Correct 4 ms 764 KB Output is correct
13 Correct 3 ms 788 KB Output is correct
14 Correct 5 ms 836 KB Output is correct
15 Correct 4 ms 1040 KB Output is correct
16 Correct 35 ms 2864 KB Output is correct
17 Correct 35 ms 3956 KB Output is correct
18 Correct 36 ms 4924 KB Output is correct
19 Correct 48 ms 5948 KB Output is correct
20 Correct 29 ms 6784 KB Output is correct
21 Correct 27 ms 7760 KB Output is correct
22 Correct 35 ms 8736 KB Output is correct
23 Correct 23 ms 9712 KB Output is correct
24 Correct 27 ms 10692 KB Output is correct