Submission #1001887

# Submission time Handle Problem Language Result Execution time Memory
1001887 2024-06-19T08:19:32 Z LilPluton Watching (JOI13_watching) C++14
0 / 100
1 ms 604 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
/// author: LilPluton auuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
#define OPT         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define intt        long long
#define int         ll
#define ll          long long
#define pb          push_back
#define arr         array
#define vll         vector<int>
#define fi          first
#define se          second
#define rep(i,j,k)  for(int i = j; i <= k; ++i)
#define all(a)      a.begin(),a.end()
#define pii         pair<int,int>
#define endll       '\n'
using namespace std;
const int INF = 1e18;
const int N = 1e5 + 5;

bool check(vector<int>& a, int p,int q,int w)
{
    int n = a.size();
    int s = 0, l = 0;
    int i = 0;
    while(i < n)
    {
        if(l < q)
        {
            int en = a[i] + 2 * w;
            l++;
            while(i < n && a[i] <= en)
                ++i;
        }
        else if(s < p)
        {
            int en = a[i] + w;
            s++;
            while(i < n && a[i] <= en)
            {
                ++i;
            }
        }
        else
            return false;
    }
    return true;
}

signed main()
{
    OPT
    int n, p, q;
    cin >> n >> p >> q;
    vector<int>a(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    sort(all(a));
    int lb = 1, rb = 1e9;
    int ans;
    while(lb <= rb)
    {
        int mid = (lb + rb) / 2;
        if(check(a,p,q,mid))
        {
            ans = mid;
            rb = mid - 1;
        }
        else
        {
            lb = mid + 1;
        }
    }
    cout << lb - 1;
}

Compilation message

watching.cpp:4: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    4 | #pragma GCC optimization("unroll-loops")
      | 
watching.cpp: In function 'int main()':
watching.cpp:62:9: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   62 |     int ans;
      |         ^~~
# 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 604 KB Output isn't correct
2 Halted 0 ms 0 KB -