Submission #555048

# Submission time Handle Problem Language Result Execution time Memory
555048 2022-04-30T04:01:30 Z don2001 Stove (JOI18_stove) C++14
100 / 100
278 ms 2220 KB
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll mod=1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main(){fast
	int n,k; cin>>n>>k; vector<int>t(n);
	for(int i=0;i<n;i++){
		cin>>t[i];
	}
	vector<int>p;
	for(int i=1;i<n;i++){
		p.push_back(t[i]-t[i-1]-1);
	}
	sort(p.rbegin(),p.rend());
	for(int i=0;i<n-k;i++){
		p.pop_back();
	}
	debug(p);
	int ans=t[n-1]-t[0]+1;
	for(int i=0;i<p.size();i++){
		ans-=p[i];
	}
	cout<<ans<<"\n";
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:49:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for(int i=0;i<p.size();i++){
      |              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 6 ms 348 KB Output is correct
14 Correct 8 ms 380 KB Output is correct
15 Correct 9 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 6 ms 348 KB Output is correct
14 Correct 8 ms 380 KB Output is correct
15 Correct 9 ms 384 KB Output is correct
16 Correct 18 ms 1368 KB Output is correct
17 Correct 18 ms 1372 KB Output is correct
18 Correct 20 ms 1368 KB Output is correct
19 Correct 40 ms 1368 KB Output is correct
20 Correct 141 ms 1576 KB Output is correct
21 Correct 276 ms 2000 KB Output is correct
22 Correct 246 ms 2172 KB Output is correct
23 Correct 251 ms 2136 KB Output is correct
24 Correct 278 ms 2220 KB Output is correct