# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
92097 |
2019-01-01T14:19:00 Z |
karma |
Stove (JOI18_stove) |
C++11 |
|
23 ms |
2420 KB |
#include<bits/stdc++.h>
#define For(i, a, b) for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName "test"
#define ll long long
#define ld long double
#define ull unsigned long
#define Print(x) cerr << #x << "is " << x << '\n';
#define pb push_back
#define X first
#define Y second
//#define Karma
using namespace std;
template<typename T> inline void Cin(T &x)
{
char c;
T sign = 1;
x = 0;
for (c = getchar(); c < '0' || c > '9'; c = getchar())
if (c == '-') sign = -1;
for (; c >= '0' && c <= '9'; c = getchar())
x = x * 10 + c - '0';
x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 1e5 + 7;
ll n, k, x, pre;
priority_queue<ll, vector<ll>, greater<ll>> pq;
void Enter()
{
Cin(n, k);
For(i, 1, n)
{
Cin(x);
if(i > 1) pq.push(x - pre - 1);
pre = x;
}
}
void Solve()
{
while(pq.size() >= k && !pq.empty()) n += pq.top(), pq.pop();
cout << n;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef Karma
freopen(FileName".inp", "r", stdin);
freopen(FileName".out", "w", stdout);
#endif // Karma
Enter();
Solve();
return 0;
}
Compilation message
stove.cpp: In function 'void Solve()':
stove.cpp:52:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(pq.size() >= k && !pq.empty()) n += pq.top(), pq.pop();
~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
2 ms |
504 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Correct |
2 ms |
476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
2 ms |
504 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Correct |
2 ms |
476 KB |
Output is correct |
16 |
Correct |
23 ms |
2420 KB |
Output is correct |
17 |
Correct |
23 ms |
2420 KB |
Output is correct |
18 |
Correct |
23 ms |
2420 KB |
Output is correct |
19 |
Correct |
22 ms |
2420 KB |
Output is correct |
20 |
Correct |
18 ms |
2420 KB |
Output is correct |
21 |
Correct |
13 ms |
2416 KB |
Output is correct |
22 |
Correct |
12 ms |
2420 KB |
Output is correct |
23 |
Correct |
13 ms |
2420 KB |
Output is correct |
24 |
Correct |
12 ms |
2420 KB |
Output is correct |