답안 #1113284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1113284 2024-11-16T09:42:40 Z hpesoj Stove (JOI18_stove) C++17
100 / 100
26 ms 3388 KB
#include <bits/stdc++.h>
#define int long long
#define pi pair<int, int>
#define ppi pair<pi, int>
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << '\n'
#define debug2(x, y) cout << #x << ": " << x << ' ' << #y << ": " << y << '\n'
#define debug3(x, y, z) cout << #x << ": " << x << ' ' << #y << ": " << y << ' ' << #z << ": " << z << '\n'
using namespace std;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const int inf = 1e18+5, mod = 1000000007;
signed main(){
	ios::sync_with_stdio(0), cin.tie(0);
	int n, k; cin >> n >> k;
	int t[n+1];
	for(int i = 1; i <= n; i++) cin >> t[i];
	int ans = n;
	priority_queue <int, vector <int>, greater <int>> pq;
	for(int i = 2; i <= n; i++) if(t[i] - t[i-1] > 1) pq.push(t[i] - t[i-1] - 1);
	while(pq.size() >= k) ans += pq.top(), pq.pop();
	cout << ans;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:25:18: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   25 |  while(pq.size() >= k) ans += pq.top(), pq.pop();
      |        ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 460 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 460 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 420 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 460 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 460 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 420 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 460 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 460 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 420 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 476 KB Output is correct
16 Correct 26 ms 3388 KB Output is correct
17 Correct 21 ms 3252 KB Output is correct
18 Correct 25 ms 3360 KB Output is correct
19 Correct 26 ms 3280 KB Output is correct
20 Correct 17 ms 3280 KB Output is correct
21 Correct 14 ms 3280 KB Output is correct
22 Correct 15 ms 3272 KB Output is correct
23 Correct 11 ms 3280 KB Output is correct
24 Correct 11 ms 3280 KB Output is correct