답안 #732248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
732248 2023-04-28T19:45:59 Z blackslex Stove (JOI18_stove) C++17
100 / 100
29 ms 2956 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 1e5 + 5;
ll n, m, a[N], ans;
vector<ll> v;

int main() {
    scanf("%lld %lld %lld", &n, &m, &a[1]);
    for (int i = 2; i <= n; i++) scanf("%lld", &a[i]), v.emplace_back(a[i] - a[i - 1] - 1);
    sort(v.begin(), v.end());
    for (int i = 0; i < n - m; i++) ans += v[i];
    printf("%lld", ans + n);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld %lld %lld", &n, &m, &a[1]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:12:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (int i = 2; i <= n; i++) scanf("%lld", &a[i]), v.emplace_back(a[i] - a[i - 1] - 1);
      |                                  ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 264 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 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 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 264 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 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 212 KB Output is correct
10 Correct 1 ms 376 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 324 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 264 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 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 212 KB Output is correct
10 Correct 1 ms 376 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 324 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 29 ms 2924 KB Output is correct
17 Correct 18 ms 2872 KB Output is correct
18 Correct 19 ms 2904 KB Output is correct
19 Correct 24 ms 2884 KB Output is correct
20 Correct 23 ms 2904 KB Output is correct
21 Correct 19 ms 2956 KB Output is correct
22 Correct 20 ms 2956 KB Output is correct
23 Correct 20 ms 2888 KB Output is correct
24 Correct 20 ms 2920 KB Output is correct