Submission #20903

#TimeUsernameProblemLanguageResultExecution timeMemory
20903exqt격자 보존하기 (GA9_preserve)C++14
100 / 100
66 ms2804 KiB
#include <iostream> #include <algorithm> #include <vector> #include <utility> #include <string> #include <set> #include <ctime> using namespace std; int main() { int n, k, d; cin >> n >> k >> d; vector<int> v(k); for(int i=0; i<k; i++) cin >> v[i]; vector<int> gp(k); gp[0] = 0; for(int i=0; i<k-1; i++) gp[i+1] = v[i+1]-v[i]-1; sort(gp.begin()+1, gp.end()); reverse(gp.begin()+1, gp.end()); for(int i=1; i<gp.size(); i++) gp[i] += gp[i-1]; int g1 = v.front()-1; int g2 = n-v.back(); int res = 0; int lim = gp.size()-1; res = max(res, gp[min((d )/2, lim)]); if(d >= 2) res = max(res, gp[min((d-2)/2, lim)]+g1+g2); res = max(res, gp[min((d-1)/2, lim)]+max(g1, g2)); cout << res << endl; return 0; }

Compilation message (stderr)

preserve.cpp: In function 'int main()':
preserve.cpp:24:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1; i<gp.size(); i++) gp[i] += gp[i-1];
                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...