답안 #520343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
520343 2022-01-29T14:39:40 Z new_acc Stove (JOI18_stove) C++14
0 / 100
1 ms 328 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(a, b) for(int a = 0; a < (b); a++)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<ll> vl;
const int N=1e6+10;
int t[N];
void solve(){
	int n,k;
	cin>>n>>k;
	rep(i,n) cin>>t[i];
	vi v;
	sort(t,t+n);
	ll curr=0;
	curr=t[n-1]-t[0]+1;
	for(int i=1;i<n;i++) v.push_back(t[i]-t[i-1]-1);
	sort(v.begin(),v.end());
	for(int i=v.size()-1;i>v.size()-k;i--) curr-=v[i];
	cout<<curr<<"\n";
}
int main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	solve();
}

Compilation message

stove.cpp: In function 'void solve()':
stove.cpp:21:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i=v.size()-1;i>v.size()-k;i--) curr-=v[i];
      |                       ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Incorrect 0 ms 208 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Incorrect 0 ms 208 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Incorrect 0 ms 208 KB Output isn't correct
6 Halted 0 ms 0 KB -