Submission #1094209

#TimeUsernameProblemLanguageResultExecution timeMemory
1094209Roumak77Inspections (NOI23_inspections)C++17
29 / 100
1084 ms1048576 KiB
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;

using ll = long long;

void solve(){

    ll n, m, q;
    cin >> n >> m >> q;
    ll curr = 0;
    vector<ll> total;
    vector<vector<ll>> list_n(n, vector<ll>{});

    for(ll i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        for(ll j = a; j <= b; j++){
            list_n[j].push_back(j - a + curr);
        }
        curr += b - a + 1;
    }

    for(ll i = 0; i < n; i++){
        if(list_n[i].empty()){
            continue;
        }
        sort(list_n[i].begin(), list_n[i].end());
        for(ll j = 0; j < list_n[i].size() - 1; j++){
            //cout << j << " " << list_n[i].size() << endl;
            total.push_back(list_n[i][j + 1] - list_n[i][j]);
        }
    }

    sort(total.begin(), total.end());

    for(ll i = 0; i < q; i++){
        ll temp;
        cin >> temp;


        ll l = -1;
        ll r = total.size();


        while(l + 1 < r){
            ll mid = (l + r)/2;

            if(total[mid] > temp){
                r = mid;
            }else{
                l = mid;
            }
        }

        cout << total.size() - r << " ";

    }

}

bool single = true;

int main(){

    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);

    ll t = 1;
    if(!single) cin >> t;

    while(t--){
        solve();
    }
}

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:41:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(ll j = 0; j < list_n[i].size() - 1; j++){
      |                       ~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...