Submission #1306168

#TimeUsernameProblemLanguageResultExecution timeMemory
1306168baodatStove (JOI18_stove)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define FOR(i, l, r) for(int i = l; i <= r; i++) #define FORD(i, l, r) for(int i = l; i >= r; i--) #define pb push_back signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector<ll>a(n); FOR(i, 0, n - 1) cin >> a[i]; if(k == n) return void(cout << n << "\n"); vector<ll> ds; FOR(i, 0, n - 2){ ll t = a[i + 1] - (a[i] + 1); if(t > 0) ds.pb(t); } sort(ds.begin(), ds.end()); int ans = n; FOR(i, 0, (int)ds.size() - (k - 1) - 1) ans += ds[i]; cout << ans << "\n"; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:14:21: error: void value not ignored as it ought to be
   14 |   if(k == n) return void(cout << n << "\n");
      |                     ^~~~~~~~~~~~~~~~~~~~~~~