Submission #1001870

# Submission time Handle Problem Language Result Execution time Memory
1001870 2024-06-19T08:10:43 Z vjudge1 Watching (JOI13_watching) C++17
0 / 100
13 ms 644 KB
#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], 1});
    }
    vector<int> fi, se;
    while (s.size() > p + q){
        fi = {0, 0, 1}, se = {1000000000, 1000000000, 1};
        auto it = s.begin();
        while(it != s.end()){
            auto ne = next(it);
            if (ne != s.end()){
                if (ne->at(1) - it->at(0) < se[1] - fi[0]){
                    fi = *it;
                    se = *ne;
                }
            }
            it = ne;
        }
        vector<int> fu = {fi[0], se[1], se[1] - fi[0] + 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

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 time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 644 KB Output isn't correct
2 Halted 0 ms 0 KB -