답안 #539692

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
539692 2022-03-19T06:26:02 Z krit3379 Stove (JOI18_stove) C++17
100 / 100
38 ms 2228 KB
#include<bits/stdc++.h>
using namespace std;
#define N 100005

int t[N];
priority_queue<int> q;

int main(){
    int n,k,i,ans;
    scanf("%d %d",&n,&k);
    ans=n;
    for(i=1;i<=n;i++){
        scanf("%d",&t[i]);
        if(i>1)q.push(t[i]-t[i-1]-1);
    }
    while(!q.empty()&&--k)q.pop();
    while(!q.empty())ans+=q.top(),q.pop();
    printf("%d",ans);
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~~
stove.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&t[i]);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 360 KB Output is correct
13 Correct 2 ms 356 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 360 KB Output is correct
13 Correct 2 ms 356 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 38 ms 2160 KB Output is correct
17 Correct 25 ms 2104 KB Output is correct
18 Correct 34 ms 2096 KB Output is correct
19 Correct 32 ms 2228 KB Output is correct
20 Correct 25 ms 2084 KB Output is correct
21 Correct 26 ms 2128 KB Output is correct
22 Correct 27 ms 2136 KB Output is correct
23 Correct 28 ms 2216 KB Output is correct
24 Correct 27 ms 2104 KB Output is correct