Submission #1001570

# Submission time Handle Problem Language Result Execution time Memory
1001570 2024-06-19T05:58:26 Z ayankarimova Watching (JOI13_watching) C++14
0 / 100
1 ms 472 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll sz=2005;
ll m[sz];
vector<ll>s, t;
vector<pair<ll, ll>>d;
/*
{} []
*/
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n, p, q;
    cin>>n>>p>>q;
    for(int i=1; i<=n; i++){
        cin>>m[i];
    }
    sort(m+1, m+n+1);
    for(int i=2; i<=n; i++){
        d.push_back({m[i]-m[i-1], i-1});

    }
    ll last=1, mx=0;
    sort(d.rbegin(), d.rend());
    //for(auto i:d) cout<<i.first<<' '<<i.second<<endl;;
    //cout<<endl;
    for(int i=0; i<min(p+q-1, (ll)d.size()); i++){
        t.push_back(d[i].second);
    }
    sort(t.begin(), t.end());
    for(int i=0; i<t.size(); i++){
        s.push_back(m[t[i]]-m[last]+1);
        last=t[i]+1;
    }
    s.push_back(m[n]-m[last]+1);
    sort(s.begin(), s.end());
    //for(auto i:s) cout<<i<<' ';
    for(int i=0; i<p; i++)
        mx=max(mx, s[i]);
    for(int i=p; i<p+q; i++)
        mx=max(mx, (s[i]+1)/2);
    cout<<mx;
}
/*
{} []
33
66
99
10
83
68
19
83
93
53
15
66
75
10 15 19 -
33 -
53 -
66 66 68  75 -
83 83 93 99

10 1 1 10 17
*/

Compilation message

watching.cpp: In function 'int main()':
watching.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0; i<t.size(); i++){
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 472 KB Output isn't correct
2 Halted 0 ms 0 KB -