제출 #960992

#제출 시각아이디문제언어결과실행 시간메모리
960992aminjon__Stove (JOI18_stove)C++17
100 / 100
18 ms2188 KiB
#include<bits/stdc++.h> #define all(x) (x).begin() , (x).end() #define endl '\n' typedef long long ll; typedef long double ld; typedef unsigned long long ull; using namespace std; void solve(){ int n , k; cin >> n >> k; vector <int> t(n); vector <int> gaps(n); for(int i = 0;i < n;i++){ cin >> t[i]; if(i > 0){ gaps[i] = t[i]-t[i-1]-1; } } int ans = t[n-1]-t[0]+1; sort(gaps.begin()+1 , gaps.end() ,greater<ll>()); for(int j = 0;j < gaps.size();j++){ if(k > 0){ k--; ans -= gaps[j]; } } cout<<ans<<endl; } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); ll t=1; //cin>>t; while(t--){ solve(); } return 0; }

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

stove.cpp: In function 'void solve()':
stove.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int j = 0;j < gaps.size();j++){
      |                   ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...