# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28445 | 2017-07-16T06:01:45 Z | 맞왜틀 맞왜틀 신나는노래~ 헤이! 나도한번 불러보자(#1216, skdudn321, choiking10) | Wine Tasting (FXCUP2_wine) | C++11 | 0 ms | 1932 KB |
#include <cstdio> #include <algorithm> #include <vector> int main(){ int N,K; scanf("%d%d",&N,&K); std::vector<int> D(N+1); std::vector<int> ans; int mval = 0; for(int i =1 ; i <= N; i++){ scanf("%d",&D[i]); } std::vector<int> plus,minus; for(int i = 0; i <= N ;){ int s = i; while(i+1 <= N && D[i] <= D[i+1]) i++; if(s != i){ plus.push_back(D[i]-D[s]); if(ans.size() != 0) minus.push_back(D[s]-ans.back()); ans.push_back(D[s]); ans.push_back(D[i]); } i++; } long long tot = 0; std::sort(minus.begin(),minus.end()); for(auto i : plus){ tot += i; } int pused = plus.size()*2-1; while(pused > K){ pused-=2; tot+=minus.back(); minus.pop_back(); } printf("%lld",tot); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1932 KB | Output is correct |
2 | Correct | 0 ms | 1932 KB | Output is correct |
3 | Incorrect | 0 ms | 1932 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |