Submission #780979

# Submission time Handle Problem Language Result Execution time Memory
780979 2023-07-12T15:17:07 Z Mouad_ouj Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 1360 KB
#include "towers.h" //sub1
#include <bits/stdc++.h>
using namespace std;
vector<int> he;
int k=-1;
void init (int n,vector<int> h)
{
    he.resize(n);
    for(int x=0;x<n;x++)
    {
    he[x]=h[x];
    if(h[x]>h[x+1] && x!=n && k==-1)
    k=x;
    }
    if(h[n-1]>h[n-2])
    k=n-1;
}
int max_towers(int l, int r, int d)
{
    if(l==r)
    return 1;
    //if(k>r || k<l || he[r]>he[k]-d || he[l]>he[k]-d)
    //return 0;
    int ml=k,mr=r;
    while(ml!=mr)
    {
        int mid=(ml+mr)/2;
        if(he[mid]>he[k]-d)
        ml=mid+1;
        else
        mr=mid;
    }
    int a1=mr,a2=0;
    ml=l,mr=k;
    while(ml!=mr)
    {
        int mid=(ml+mr)/2;
        if(he[mid]<he[k]-d)
        ml=mid+1;
        else
        mr=mid;
    }
    a2=mr;
    return ((r-a1+1)+(a2-l));
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4058 ms 976 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4073 ms 208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4073 ms 208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4059 ms 1360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 208 ms 560 KB 1st lines differ - on the 1st token, expected: '7197', found: '12081'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4073 ms 208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4058 ms 976 KB Time limit exceeded
2 Halted 0 ms 0 KB -