# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
828108 |
2023-08-17T05:03:58 Z |
반딧불(#10380) |
Inspections (NOI23_inspections) |
C++17 |
|
261 ms |
36700 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = -1e18;
ll n; int k, q;
ll l[200002], r[200002];
ll query[200002];
struct dat{
ll l, r, st; /// 구간의 왼쪽 끝점, 오른쪽 끝점, 시작 시간
dat(){}
dat(ll l, ll r, ll st): l(l), r(r), st(st){}
bool operator<(const dat &nxt)const{
if(l!=nxt.l) return l<nxt.l;
return r<nxt.r;
}
};
set<dat> st;
vector<pair<ll, ll> > ans;
int main(){
scanf("%lld %d %d", &n, &k, &q);
for(int i=1; i<=k; i++) scanf("%lld %lld", &l[i], &r[i]);
for(int i=1; i<=q; i++) scanf("%lld", &query[i]), query[i]++;
st.insert(dat(1, n, INF));
ll len = 1;
for(int i=1; i<=k; i++){
vector<dat> vec;
auto it = prev(st.lower_bound(dat(l[i], INT_MAX, 0)));
while(it != st.end() && it->l <= r[i]){
vec.push_back(*it);
++it;
st.erase(prev(it));
}
//printf("i=%d\n", i);
for(dat p: vec){
if(p.l < l[i]) st.insert(dat(p.l, l[i]-1, p.st));
if(r[i] < p.r) st.insert(dat(r[i]+1, p.r, p.st + (r[i]+1) - p.l));
//printf("p is (%lld, %lld) %lld\n", p.l, p.r, p.st);
if(p.st < 0) continue;
int s = max(p.l, l[i]), e = min(p.r, r[i]);
ll nowT = len + s - l[i], prvT = p.st + s - p.l;
ans.push_back(make_pair(nowT - prvT, e-s+1));
}
st.insert(dat(l[i], r[i], len));
len += r[i]-l[i]+1;
//printf("Set now: ");
//for(auto p: st) printf("(%lld, %lld) %lld ", p.l, p.r, p.st);
//puts("");
}
sort(ans.begin(), ans.end());
ans.push_back(make_pair(LLONG_MAX, 0));
for(int i=(int)ans.size()-2; i>=0; i--){
ans[i].second += ans[i+1].second;
}
#ifdef TEST
for(auto p: ans) printf("(%lld, %lld) ", p.first, p.second);
#endif
for(int i=1; i<=q; i++){
printf("%lld ", lower_bound(ans.begin(), ans.end(), make_pair(query[i], -1LL))->second);
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf("%lld %d %d", &n, &k, &q);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:27:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | for(int i=1; i<=k; i++) scanf("%lld %lld", &l[i], &r[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:28:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | for(int i=1; i<=q; i++) scanf("%lld", &query[i]), query[i]++;
| ~~~~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
0 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
0 ms |
308 KB |
Output is correct |
13 |
Correct |
35 ms |
3928 KB |
Output is correct |
14 |
Correct |
31 ms |
3404 KB |
Output is correct |
15 |
Correct |
32 ms |
3964 KB |
Output is correct |
16 |
Correct |
38 ms |
4104 KB |
Output is correct |
17 |
Correct |
33 ms |
3916 KB |
Output is correct |
18 |
Correct |
34 ms |
3872 KB |
Output is correct |
19 |
Correct |
41 ms |
4168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
36 ms |
3820 KB |
Output is correct |
4 |
Correct |
36 ms |
4536 KB |
Output is correct |
5 |
Correct |
148 ms |
16480 KB |
Output is correct |
6 |
Correct |
133 ms |
17468 KB |
Output is correct |
7 |
Correct |
116 ms |
12324 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
0 ms |
308 KB |
Output is correct |
13 |
Correct |
35 ms |
3928 KB |
Output is correct |
14 |
Correct |
31 ms |
3404 KB |
Output is correct |
15 |
Correct |
32 ms |
3964 KB |
Output is correct |
16 |
Correct |
38 ms |
4104 KB |
Output is correct |
17 |
Correct |
33 ms |
3916 KB |
Output is correct |
18 |
Correct |
34 ms |
3872 KB |
Output is correct |
19 |
Correct |
41 ms |
4168 KB |
Output is correct |
20 |
Correct |
46 ms |
5156 KB |
Output is correct |
21 |
Correct |
35 ms |
4316 KB |
Output is correct |
22 |
Correct |
55 ms |
5152 KB |
Output is correct |
23 |
Correct |
32 ms |
4132 KB |
Output is correct |
24 |
Correct |
32 ms |
3916 KB |
Output is correct |
25 |
Correct |
49 ms |
4536 KB |
Output is correct |
26 |
Correct |
42 ms |
5196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
0 ms |
308 KB |
Output is correct |
13 |
Correct |
35 ms |
3928 KB |
Output is correct |
14 |
Correct |
31 ms |
3404 KB |
Output is correct |
15 |
Correct |
32 ms |
3964 KB |
Output is correct |
16 |
Correct |
38 ms |
4104 KB |
Output is correct |
17 |
Correct |
33 ms |
3916 KB |
Output is correct |
18 |
Correct |
34 ms |
3872 KB |
Output is correct |
19 |
Correct |
41 ms |
4168 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
36 ms |
3820 KB |
Output is correct |
23 |
Correct |
36 ms |
4536 KB |
Output is correct |
24 |
Correct |
148 ms |
16480 KB |
Output is correct |
25 |
Correct |
133 ms |
17468 KB |
Output is correct |
26 |
Correct |
116 ms |
12324 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
46 ms |
5156 KB |
Output is correct |
30 |
Correct |
35 ms |
4316 KB |
Output is correct |
31 |
Correct |
55 ms |
5152 KB |
Output is correct |
32 |
Correct |
32 ms |
4132 KB |
Output is correct |
33 |
Correct |
32 ms |
3916 KB |
Output is correct |
34 |
Correct |
49 ms |
4536 KB |
Output is correct |
35 |
Correct |
42 ms |
5196 KB |
Output is correct |
36 |
Correct |
245 ms |
25024 KB |
Output is correct |
37 |
Correct |
218 ms |
25476 KB |
Output is correct |
38 |
Correct |
194 ms |
26376 KB |
Output is correct |
39 |
Correct |
145 ms |
17312 KB |
Output is correct |
40 |
Correct |
195 ms |
26196 KB |
Output is correct |
41 |
Correct |
221 ms |
36604 KB |
Output is correct |
42 |
Correct |
219 ms |
36700 KB |
Output is correct |
43 |
Correct |
261 ms |
32436 KB |
Output is correct |
44 |
Correct |
244 ms |
33328 KB |
Output is correct |
45 |
Correct |
213 ms |
25744 KB |
Output is correct |
46 |
Correct |
255 ms |
19564 KB |
Output is correct |
47 |
Correct |
235 ms |
20112 KB |
Output is correct |
48 |
Correct |
192 ms |
26148 KB |
Output is correct |