Submission #555048

#TimeUsernameProblemLanguageResultExecution timeMemory
555048don2001Stove (JOI18_stove)C++14
100 / 100
278 ms2220 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...