Submission #1001827

#TimeUsernameProblemLanguageResultExecution timeMemory
1001827HasanV11010238Watching (JOI13_watching)C++17
0 / 100
14 ms644 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define INF 1000000000 int n, p, q; vector<int> a; int main(){ cin>>n>>p>>q; a.resize(n + 1); for (int i = 1; i <= n; i++){ cin>>a[i]; } set<vector<int>> s; for (int i = 1; i <= n; i++){ s.insert({a[i], a[i]}); } vector<int> fi, se; while (s.size() > p + q){ fi = {0, 0}, se = {1000000000, 1000000000}; auto it = s.begin(); while(it != s.end()){ auto ne = next(it); if (ne != s.end()){ if (ne->at(0) - it->at(1) < se[0] - fi[1]){ fi = *it; se = *ne; } } it = ne; } vector<int> fu = {fi[0], se[1]}; s.erase(fi); s.erase(se); s.insert(fu); } vector<int> fin; for (auto el : s){ fin.push_back(el[1] - el[0] + 1); } sort(fin.begin(), fin.end()); reverse(fin.begin(), fin.end()); int ans = 0; for (int i = 0; i < p + q; i++){ if (i < q){ ans = max(ans, int(ceil(double(fin[i]) / (double)2))); } else{ ans = max(ans, fin[i]); } } cout<<ans; }

Compilation message (stderr)

watching.cpp: In function 'int main()':
watching.cpp:18:21: warning: comparison of integer expressions of different signedness: 'std::set<std::vector<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     while (s.size() > p + q){
      |            ~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...