Submission #629297

# Submission time Handle Problem Language Result Execution time Memory
629297 2022-08-14T10:49:19 Z peti1234 Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 7896 KB
#include <bits/stdc++.h>

using namespace std;
const int c=100005;
int n, t[c];
set<pair<int, int> > s;
vector<pair<int, pair<int, int> > > sz;
void init(int N, vector<int> sz) {
    n=N;
    for (int i=0; i<n; i++) {
        t[i+1]=sz[i];
    }
}


int max_towers(int l, int r, int d) {
    l++, r++;
    for (int i=l-1; i<=r+1; i++) {
        s.insert({i, 1});
    }

    for (int i=l; i<=r; i++) {
        sz.push_back({t[i], {1, i}}), sz.push_back({t[i]+d, {0, i}});
    }
    sort(sz.begin(), sz.end());

    int maxi=0, ert=0;
    for (auto x:sz) {
        int id=x.second.first, pos=x.second.second;
        //cout << "fontos " << pos << " " << id << "\n";
        if (!id) {
            s.insert({pos, id});
        }
        auto it=s.upper_bound({pos, -1});
        int cnt=0;
        it++;
        cnt+=(*it).second;
        it--, it--;
        cnt+=(*it).second;

        if (id==0) {
            if (cnt==2) {
                ert++;
            }
        }
        if (id==1) {
            if (!cnt) {
                ert--;
            }
            s.erase({pos, id});
        }
        maxi=max(maxi, ert);
    }
    s.clear(), sz.clear();

    return maxi;
}
/*
int main()
{
    int N;
    vector<int> P;
    cin >> N;
    for (int i=0; i<N; i++) {
        int x;
        cin >> x;
        P.push_back(x);
    }
    init(N, P);
    int q;
    cin >> q;
    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        cout << max_towers(l, r, d) << "\n";
    }
    return 0;
}
*/
/*
7
10 20 60 40 50 30 70
1
1 5 10
*/
# Verdict Execution time Memory Grader output
1 Execution timed out 4017 ms 4732 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4006 ms 7896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 2496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4017 ms 4732 KB Time limit exceeded
2 Halted 0 ms 0 KB -