Submission #825126

# Submission time Handle Problem Language Result Execution time Memory
825126 2023-08-14T14:37:58 Z alvingogo Radio Towers (IOI22_towers) C++17
0 / 100
462 ms 1432 KB
#include "towers.h"
#include <bits/stdc++.h>
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

vector<int> v;
int mx;
int n;
void init(int N, vector<int> h) {
    v=h;
    n=N;
    mx=0;
    for(int i=1;i<n;i++){
        if(v[i]>v[mx]){
            mx=i;
        }
    }
}

int max_towers(int L, int R, int d) {
    if(L>=mx || R<=mx){
        return 0;
    }
    int u=0;
    int a=0,b=0;
    if(mx!=0){
        int l=0,r=mx-1;
        while(r>l){
            int m=(l+r+1)/2;
            if(v[m]+d>v[mx]){
                r=m-1;
            }
            else{
                l=m;
            }
        }
        a=max(0,l-L+1);
    }
    if(mx+1!=n){
        int l=mx+1,r=n-1;
        while(r>l){
            int m=(l+r)/2;
            if(v[m]+d>v[mx]){
                l=m+1;
            }
            else{
                r=m;
            }
        }
        b=max(0,R-l+1);
    }
    if(a==0 || b==0){
        return 1;
    }
    return 2;
}

Compilation message

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:26:9: warning: unused variable 'u' [-Wunused-variable]
   26 |     int u=0;
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 224 ms 920 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 462 ms 1432 KB 1st lines differ - on the 1st token, expected: '11903', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 210 ms 552 KB 1st lines differ - on the 1st token, expected: '7197', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 224 ms 920 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -