2514 | 2023-01-15 11:55:36 | Zoli9 | Videójáték | cpp17 | Accepted 100/100 | 186ms | 7380 KiB |
//HZsófi
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n;
cin>>t>>n;
vector<pair<int, int>> fsz(n+1);
for(int i=1; i<n+1; i++){
cin>>fsz[i].first;
cin>>fsz[i].second;
}
int m;
cin>>m;
vector<pair<int, int>> haha(m+1);
for(int i=1; i<m+1; i++){
cin>>haha[i].first;
cin>>haha[i].second;
}
int megoldas=0;
int hszaml=1;
for(int i=1; i<n+1; i++) {
//itt megjön a főszereplő az i. szünetre
/*
amíg hszaml szünet intervallum az túl kicsi, addig fellépegetünk
...utána most már a közös szünetes dolgokat vizsgáljuk
...és utána ha elment a főszereplő, vagy már túl messze van a hszaml szünet, akkor kilépünk
*/
while(hszaml<=m && haha[hszaml].second<fsz[i].first){
hszaml++;
}
if(hszaml>m) {
break;
}
int fszido=fsz[i].first;
while(1) {
if(haha[hszaml].first>fsz[i].second){
break;
}
if(fszido+t<haha[hszaml].first){
break;
}
int mini=min(haha[hszaml].second, fsz[i].second);
int maxi=max(haha[hszaml].first, fszido);
megoldas+=mini-maxi+1;
if(i+1<=n){
if( fsz[i+1].first>haha[hszaml].second){
hszaml++;
} else {
break;
}
}
else{
hszaml++;
}
fszido=mini+1;
if(hszaml>m) {
break;
}
}
}
cout<<megoldas;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1812 KiB | ||||
2 | Accepted | 2ms | 2060 KiB | ||||
subtask2 | 10/10 | ||||||
3 | Accepted | 2ms | 2260 KiB | ||||
4 | Accepted | 2ms | 2408 KiB | ||||
5 | Accepted | 2ms | 2664 KiB | ||||
6 | Accepted | 2ms | 2900 KiB | ||||
7 | Accepted | 2ms | 3064 KiB | ||||
8 | Accepted | 2ms | 3316 KiB | ||||
9 | Accepted | 2ms | 3348 KiB | ||||
10 | Accepted | 2ms | 3556 KiB | ||||
11 | Accepted | 2ms | 3636 KiB | ||||
subtask3 | 20/20 | ||||||
12 | Accepted | 2ms | 3748 KiB | ||||
13 | Accepted | 2ms | 3716 KiB | ||||
14 | Accepted | 2ms | 3824 KiB | ||||
15 | Accepted | 2ms | 3988 KiB | ||||
16 | Accepted | 2ms | 3844 KiB | ||||
17 | Accepted | 3ms | 3856 KiB | ||||
18 | Accepted | 3ms | 3852 KiB | ||||
19 | Accepted | 4ms | 3872 KiB | ||||
20 | Accepted | 3ms | 3844 KiB | ||||
21 | Accepted | 3ms | 3836 KiB | ||||
22 | Accepted | 2ms | 4064 KiB | ||||
subtask4 | 30/30 | ||||||
23 | Accepted | 14ms | 4416 KiB | ||||
24 | Accepted | 48ms | 5008 KiB | ||||
25 | Accepted | 122ms | 6672 KiB | ||||
26 | Accepted | 136ms | 7060 KiB | ||||
27 | Accepted | 136ms | 7292 KiB | ||||
28 | Accepted | 54ms | 5720 KiB | ||||
29 | Accepted | 10ms | 4616 KiB | ||||
30 | Accepted | 9ms | 4568 KiB | ||||
31 | Accepted | 7ms | 4528 KiB | ||||
subtask5 | 40/40 | ||||||
32 | Accepted | 16ms | 4812 KiB | ||||
33 | Accepted | 59ms | 5356 KiB | ||||
34 | Accepted | 112ms | 6400 KiB | ||||
35 | Accepted | 159ms | 6948 KiB | ||||
36 | Accepted | 186ms | 7380 KiB | ||||
37 | Accepted | 180ms | 7376 KiB | ||||
38 | Accepted | 93ms | 6312 KiB | ||||
39 | Accepted | 112ms | 7072 KiB | ||||
40 | Accepted | 28ms | 5024 KiB | ||||
41 | Accepted | 43ms | 5492 KiB |