Submission #1022578

# Submission time Handle Problem Language Result Execution time Memory
1022578 2024-07-13T18:39:54 Z JakobZorz Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 3308 KB
#include"towers.h"
#include<vector>
#include<iostream>
using namespace std;

vector<int>arr;

void init(int N,vector<int>H){
    arr=H;
}

int solve(vector<int>arr,int d){
    vector<int>arr2=arr;
    arr.clear();
    arr2.insert(arr2.begin(),1e9+1);
    arr2.push_back(1e9+1);
    
    for(int i=1;i<(int)arr2.size()-1;i++){
        if(arr2[i-1]<arr2[i]&&arr2[i+1]<arr2[i])
            arr.push_back(arr2[i]);
        if(arr2[i-1]>arr2[i]&&arr2[i+1]>arr2[i])
            arr.push_back(arr2[i]);
    }
    
    while(true){
        bool removed=false;
        for(int i=1;i<(int)arr.size();i+=2){
            if(arr[i]-max(arr[i-1],arr[i+1])<d){
                removed=true;
                arr[i-1]=min(arr[i-1],arr[i+1]);
                arr.erase(arr.begin()+i);
                arr.erase(arr.begin()+i);
                break;
            }
        }
        if(!removed)
            break;
    }
    
    return (arr.size()+1)/2;
}

int max_towers(int L,int R,int D){
    vector<int>arr2;
    for(int i=L;i<=R;i++)
        arr2.push_back(arr[i]);
    return solve(arr2,D);
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4035 ms 2344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '91', found: '69'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '91', found: '69'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4010 ms 3308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4005 ms 1228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '91', found: '69'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4035 ms 2344 KB Time limit exceeded
2 Halted 0 ms 0 KB -