제출 #1017215

#제출 시각아이디문제언어결과실행 시간메모리
1017215vjudge1Stove (JOI18_stove)C++17
0 / 100
0 ms344 KiB
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ordered_set tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> #define nemeshay ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define allr(pon) pon.rbegin(), pon.rend() #define all(pon) pon.begin(), pon.end() #define nosolve cout << "-1\n" #define YES cout << "YES\n" #define Yes cout << "Yes\n" #define pii pair <int, int> #define OK cout << "OK\n" #define Ok cout << "Ok\n" #define NO cout << "NO\n" #define No cout << "No\n" #define pf push_front #define int long long #define pb push_back #define sigma signed #define sc second #define fr first using namespace __gnu_pbds; using namespace std; const int N = 1e6 + 20, INF = 1e10 + 7; int a[N], pref[N]; sigma main(){ nemeshay int n, k, ans, mx = -1; cin >> n >> k; if (k == n) { cout << n * 2; return 0; } vector <int> pon; for (int i = 0; i < n; i++) cin >> a[i]; ans = a[n - 1] + 2 - a[0]; if (k == 1) { cout << ans; return 0; } for (int i = 1; i < n; i++) pon.pb(a[i] - a[i - 1] - 1); sort (pon.rbegin(), pon.rend()); cout << ans << endl; for (int i = 0; i < k; i++) { ans -= pon[i]; cout << pon[i] << ' '; } cout << ans; }

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

stove.cpp: In function 'int main()':
stove.cpp:28:20: warning: unused variable 'mx' [-Wunused-variable]
   28 |     int n, k, ans, mx = -1;
      |                    ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...