Submission #1112860

#TimeUsernameProblemLanguageResultExecution timeMemory
1112860Roumak77Inspections (NOI23_inspections)C++17
29 / 100
2067 ms14792 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>{}); vector<pair<ll, ll>> inp; /*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 < m; i++){ ll a, b; cin >> a >> b; a--; b--; inp.push_back({a, b}); } vector<ll> ans(q, 0); vector<pair<ll, ll>> queries(q, {0, 0}); vector<ll> diff_arr(q, 0); /*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 << " "; }*/ for(ll i = 0; i < q; i++){ cin >> queries[i].first; queries[i].second = i; } sort(queries.rbegin(), queries.rend()); vector<ll> last(n, -1); curr = 0; for(ll i = 0; i < m; i++){ ll a = inp[i].first, b = inp[i].second; for(ll j = a; j <= b; j++){ ll time = j - a + curr; if(last[j] == -1){ last[j] = time; }else{ ll diff = time - last[j] - 1; ll l = -1, r = q - 1; if(queries[r].first <= diff){ while(l + 1 < r){ ll mid = (l + r)/2; if(queries[mid].first <= diff){ r = mid; }else{ l = mid; } } diff_arr[r]++; } last[j] = time; } } curr += b - a + 1; } curr = 0; for(ll i = 0; i < q; i++){ curr += diff_arr[i]; queries[i].first = curr; } for(ll i = 0; i < q; i++){ ans[queries[i].second] = queries[i].first; } for(ll i = 0; i < q; i++){ cout << ans[i] << " "; } } 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(); } }
#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...