Submission #1113159

#TimeUsernameProblemLanguageResultExecution timeMemory
1113159Tyx2019Stove (JOI18_stove)C++17
100 / 100
40 ms3312 KiB
#include <bits/stdc++.h> #define int long long #define INF 1e18 using namespace std; int N, T; int K[200005]; bool work(int tot){ int sum = 0; for(int i=0;i<N;i++){ sum += tot/K[i]; if(sum >= T) return true; } if(sum >= T) return true; else return false; } void solve(){ int N, K; cin >> N >> K; int T[N]; for(int i=0;i<N;i++) cin >> T[i]; int ans = N; vector<int> V; for(int i=1;i<N;i++) V.push_back(T[i] - T[i-1] - 1); sort(V.begin(), V.end()); for(int i=0;i<N-K;i++){ ans += V[i]; } cout << ans; } main(){ int T=1; while(T--) solve(); }

Compilation message (stderr)

stove.cpp:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...