# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1094209 | Roumak77 | Inspections (NOI23_inspections) | C++17 | 1084 ms | 1048576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |