Submission #1035062

# Submission time Handle Problem Language Result Execution time Memory
1035062 2024-07-26T03:39:34 Z irmuun Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 2256 KB
#include<bits/stdc++.h>
#include "towers.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int n;
vector<pair<int,int>>h;
vector<bool>used;

void init(int N,vector<int>H){
    n=N;
    for(int i=0;i<n;i++){
        h.pb({H[i],i});
    }
    sort(all(h));
}
int max_towers(int L,int R,int D){
    used.resize(n,0);
    int ans=0;
    for(auto [x,i]:h){
        bool add=true;
        int mx=0;
        for(int j=i-1;j>=0;j--){
            if(used[j]){
                if(mx<x+D){
                    add=false;
                }
            }
        }
        mx=0;
        for(int j=i+1;j<n;j++){
            if(used[j]){
                if(mx<x+D){
                    add=false;
                }
            }
        }
        if(add){
            ans++;
            used[i]=true;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4062 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 344 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 Execution timed out 4027 ms 2256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4064 ms 856 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 Execution timed out 4062 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -