제출 #341933

#제출 시각아이디문제언어결과실행 시간메모리
341933DrearyJokeStove (JOI18_stove)C++17
100 / 100
22 ms2924 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<bool> vb; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;} template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;} template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;} template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;} #define deb(x) cout << '>' << #x << ':' << x << endl; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define END '\n' #define inf 9e18 #define ff first #define ss second #define pb push_back void solve(){ ll n, k; cin >> n >> k; vll A(n); cin >> A; ll ans = n; ll cnt = k - 1; vll inval(n - 1); for (int i = 1; i < n; ++i) inval[i - 1] = A[i] - A[i - 1] - 1; sort(all(inval)); for (int i = 0; i < n - k; ++i) ans += inval[i]; cout << ans << END; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; // cin >> t; while(t--){ solve(); } return 0; }

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

stove.cpp: In function 'void solve()':
stove.cpp:36:8: warning: unused variable 'cnt' [-Wunused-variable]
   36 |     ll cnt = k - 1;
      |        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...