제출 #765296

#제출 시각아이디문제언어결과실행 시간메모리
765296teokakabadzeStove (JOI18_stove)C++17
100 / 100
21 ms3216 KiB
#include<bits/stdc++.h> #define f first #define s second #define pb push_back #define int long long #define N 500002 #define M 1000000007 #define pii pair<int, int> #define piii pair<pii, int> using namespace std; int n, k, i, ans, a[N]; vector<int> v; main() { std::ios::sync_with_stdio(0); cin.tie(); cin >> n >> k; for(i = 0; i < n; i++) cin >> a[i]; ans = n; sort(a, a + n); for(i = 1; i < n; i++) v.pb(a[i] - a[i - 1] - 1); sort(v.begin(), v.end()); for(i = 0; i < n - k; i++) ans += v[i]; cout << ans << '\n'; }

컴파일 시 표준 에러 (stderr) 메시지

stove.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...