Submission #1094209

# Submission time Handle Problem Language Result Execution time Memory
1094209 2024-09-29T02:26:06 Z Roumak77 Inspections (NOI23_inspections) C++17
29 / 100
1084 ms 1048576 KB
#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

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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 864 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 1 ms 872 KB Output is correct
9 Correct 1 ms 1128 KB Output is correct
10 Correct 0 ms 480 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 1 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 864 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 1 ms 872 KB Output is correct
9 Correct 1 ms 1128 KB Output is correct
10 Correct 0 ms 480 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 1 ms 360 KB Output is correct
13 Correct 117 ms 31324 KB Output is correct
14 Correct 27 ms 3284 KB Output is correct
15 Correct 154 ms 40800 KB Output is correct
16 Correct 126 ms 39076 KB Output is correct
17 Correct 38 ms 5576 KB Output is correct
18 Correct 161 ms 39628 KB Output is correct
19 Correct 123 ms 32696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 1116 KB Output is correct
3 Correct 157 ms 38828 KB Output is correct
4 Runtime error 1084 ms 1048576 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 864 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 1 ms 872 KB Output is correct
9 Correct 1 ms 1128 KB Output is correct
10 Correct 0 ms 480 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 1 ms 360 KB Output is correct
13 Correct 117 ms 31324 KB Output is correct
14 Correct 27 ms 3284 KB Output is correct
15 Correct 154 ms 40800 KB Output is correct
16 Correct 126 ms 39076 KB Output is correct
17 Correct 38 ms 5576 KB Output is correct
18 Correct 161 ms 39628 KB Output is correct
19 Correct 123 ms 32696 KB Output is correct
20 Runtime error 1043 ms 1048576 KB Execution killed with signal 9
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 864 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 1 ms 872 KB Output is correct
9 Correct 1 ms 1128 KB Output is correct
10 Correct 0 ms 480 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 1 ms 360 KB Output is correct
13 Correct 117 ms 31324 KB Output is correct
14 Correct 27 ms 3284 KB Output is correct
15 Correct 154 ms 40800 KB Output is correct
16 Correct 126 ms 39076 KB Output is correct
17 Correct 38 ms 5576 KB Output is correct
18 Correct 161 ms 39628 KB Output is correct
19 Correct 123 ms 32696 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 2 ms 1116 KB Output is correct
22 Correct 157 ms 38828 KB Output is correct
23 Runtime error 1084 ms 1048576 KB Execution killed with signal 9
24 Halted 0 ms 0 KB -