Submission #732245

# Submission time Handle Problem Language Result Execution time Memory
732245 2023-04-28T19:37:48 Z blackslex Stove (JOI18_stove) C++17
0 / 100
1 ms 212 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", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), v.emplace_back(a[i] - a[i - 1] - 1);
    sort(v.begin(), v.end());
    for (int i = 1; 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", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
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 = 1; i <= n; i++) scanf("%lld", &a[i]), v.emplace_back(a[i] - a[i - 1] - 1);
      |                                  ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -