█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 5555

Problema 0x7b - Mínimo número de salones para acomodar todas las clases

  • Autor: nivalderramas
  • Fecha: 2022-01-09 01:26:59 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.002 s 2 KBi
#2
Correcto
0.011 s 26 KBi
#3
Correcto
0.008 s 3 KBi
#4
Correcto
0.006 s 3 KBi
#5
Incorrecto
0.008 s 4 KBi
#6
Correcto
0.008 s 3 KBi
#7
Correcto
0.003 s 2 KBi
#8
Correcto
0.01 s 3 KBi
#9
Correcto
0.003 s 3 KBi
#10
Incorrecto
0.011 s 3 KBi
#11
Correcto
0.003 s 3 KBi
#12
Correcto
0.21 s 3 KBi
#13
Tiempo límite excedido
1.064 s 3 KBi
#14
Incorrecto
0.023 s 3 KBi
#15
Tiempo límite excedido
1.074 s 14 KBi
Puntos totales: 67 / 100

Código

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<n;i++)
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ostream& operator<<(ostream& os, const vector<int> &v){
    for(auto const &i: v){
        os<<i<<" ";
    }
    os<<endl;
    return os;
}
const lli mod=(1e9)+7;
const int N = 1e4+1;
struct st{
    st *left, *right;
    int l, r, mid;
    int val;
    st(int l, int r): l(l), r(r), val(0){
        if(l!=r){
            mid = (l+r)/2;
            left = new st(l,mid);
            right = new st(mid+1,r);
        }
    }

    void update(int pos){
        if(l==r){
            val += 1;
        }
        else{
            if(pos>mid)right->update(pos);
            else left->update(pos);
            val = max(left->val,right->val);
        }
    }

    int get(int a, int b){
        if(a<=l && r<=b)return val;
        if(a>=l && r>=b)return 0;
        else return max(left->get(a,b) , right->get(a,b));
    }
};
int main(){
    fast_io;
    int n;cin>>n;
    st tree(0,24600);
    REP(i,n){
        string s;cin>>s;
        int a = 0;
        int b = 0;
        string tmp = "";
        tmp += s[0];
        tmp += s[1];
        tmp += s[3];
        tmp += s[4];
        a += stoi(tmp);
        tmp = "";
        cin>>s;
        tmp += s[0];
        tmp += s[1];
        tmp += s[3];
        tmp += s[4];
        b += stoi(tmp);
        for(int k=a+1; k<b; k++){
            tree.update(k);
        }
    }
    cout<<tree.get(0,24600)<<endl;
    return 0;
}