2509 | 2023-01-15 11:38:22 | HorakZsofi | Videójáték | cpp11 | Wrong answer 10/100 | 178ms | 7800 KiB |
#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+1<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 | Wrong answer | 3ms | 1816 KiB | ||||
2 | Accepted | 2ms | 2056 KiB | ||||
subtask2 | 10/10 | ||||||
3 | Accepted | 2ms | 2144 KiB | ||||
4 | Accepted | 2ms | 2344 KiB | ||||
5 | Accepted | 2ms | 2424 KiB | ||||
6 | Accepted | 2ms | 2556 KiB | ||||
7 | Accepted | 2ms | 2796 KiB | ||||
8 | Accepted | 2ms | 2988 KiB | ||||
9 | Accepted | 2ms | 3152 KiB | ||||
10 | Accepted | 2ms | 3328 KiB | ||||
11 | Accepted | 2ms | 3452 KiB | ||||
subtask3 | 0/20 | ||||||
12 | Accepted | 2ms | 3572 KiB | ||||
13 | Accepted | 2ms | 3772 KiB | ||||
14 | Accepted | 2ms | 3856 KiB | ||||
15 | Accepted | 2ms | 3984 KiB | ||||
16 | Accepted | 2ms | 4096 KiB | ||||
17 | Accepted | 3ms | 4196 KiB | ||||
18 | Accepted | 3ms | 4264 KiB | ||||
19 | Accepted | 4ms | 4388 KiB | ||||
20 | Wrong answer | 3ms | 4384 KiB | ||||
21 | Wrong answer | 3ms | 4456 KiB | ||||
22 | Wrong answer | 2ms | 4224 KiB | ||||
subtask4 | 0/30 | ||||||
23 | Accepted | 14ms | 4628 KiB | ||||
24 | Accepted | 68ms | 5260 KiB | ||||
25 | Accepted | 127ms | 6944 KiB | ||||
26 | Accepted | 133ms | 7336 KiB | ||||
27 | Accepted | 134ms | 7336 KiB | ||||
28 | Accepted | 52ms | 5724 KiB | ||||
29 | Wrong answer | 10ms | 4860 KiB | ||||
30 | Wrong answer | 9ms | 4804 KiB | ||||
31 | Accepted | 6ms | 4692 KiB | ||||
subtask5 | 0/40 | ||||||
32 | Wrong answer | 16ms | 4928 KiB | ||||
33 | Accepted | 59ms | 5472 KiB | ||||
34 | Accepted | 111ms | 6660 KiB | ||||
35 | Accepted | 157ms | 7228 KiB | ||||
36 | Accepted | 178ms | 7652 KiB | ||||
37 | Accepted | 178ms | 7800 KiB | ||||
38 | Wrong answer | 92ms | 6568 KiB | ||||
39 | Wrong answer | 109ms | 7036 KiB | ||||
40 | Accepted | 28ms | 5120 KiB | ||||
41 | Wrong answer | 43ms | 5392 KiB |