4026 | 2023-03-09 11:55:49 | kdb | Videójáték | cpp17 | Time limit exceeded 0/100 | 2.099s | 8908 KiB |
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <tuple>
using namespace std;
signed main()
{
cin.tie(nullptr);
cout.tie(nullptr);
ios_base::sync_with_stdio(false);
int t, n;
cin >> t >> n;
vector<pair<int, int>> me;
vector<pair<int, int>> huno;
for (int i = 0; i < n; i++)
{
int x, y;
cin >> x >> y;
me.push_back(make_pair(x, y));
}
int m;
cin >> m;
for (int i = 0; i < m; i++)
{
int x, y;
cin >> x >> y;
huno.push_back(make_pair(x, y));
}
int ans = 0;
int lgame = me[0].first-1;
int mei = 0;
int hui = 0;
while (true)
{
if (me[mei].first <= huno[hui].first && me[mei].second >= huno[hui].first)
{
if (lgame + t+1 >= huno[hui].first && lgame != me[mei].second)
{
ans += min(me[mei].second, huno[hui].second) - huno[hui].first + 1;
}
}
if (me[mei].first >= huno[hui].first && me[mei].first <= huno[hui].second)
{
ans += min(me[mei].second, huno[hui].second) - me[mei].first + 1;
}
if (me[mei].second >= huno[hui].second)
{
if (lgame < huno[hui].second)
{
lgame = huno[hui].second;
hui++;
}
if (hui == m)
{
cout << ans;
return 0;
}
}
else {
mei++;
if (mei == n)
{
cout << ans;
return 0;
}
lgame = me[mei].first - 1;
}
}
}
/*
25 7
1 8 3 15 4 20 16
*/
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1832 KiB | ||||
2 | Accepted | 3ms | 2016 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Accepted | 3ms | 2228 KiB | ||||
4 | Accepted | 3ms | 2444 KiB | ||||
5 | Accepted | 3ms | 2672 KiB | ||||
6 | Time limit exceeded | 2.099s | 2872 KiB | ||||
7 | Accepted | 3ms | 3108 KiB | ||||
8 | Accepted | 2ms | 3180 KiB | ||||
9 | Accepted | 3ms | 3292 KiB | ||||
10 | Accepted | 2ms | 3364 KiB | ||||
11 | Wrong answer | 2ms | 3356 KiB | ||||
subtask3 | 0/20 | ||||||
12 | Time limit exceeded | 2.078s | 3468 KiB | ||||
13 | Time limit exceeded | 2.048s | 3556 KiB | ||||
14 | Time limit exceeded | 2.059s | 3944 KiB | ||||
15 | Time limit exceeded | 2.066s | 3916 KiB | ||||
16 | Time limit exceeded | 2.066s | 3276 KiB | ||||
17 | Time limit exceeded | 2.072s | 3920 KiB | ||||
18 | Time limit exceeded | 2.063s | 4180 KiB | ||||
19 | Time limit exceeded | 2.043s | 3496 KiB | ||||
20 | Time limit exceeded | 2.072s | 4344 KiB | ||||
21 | Time limit exceeded | 2.059s | 3480 KiB | ||||
22 | Time limit exceeded | 2.062s | 4204 KiB | ||||
subtask4 | 0/30 | ||||||
23 | Time limit exceeded | 2.075s | 3728 KiB | ||||
24 | Time limit exceeded | 2.069s | 4224 KiB | ||||
25 | Time limit exceeded | 2.072s | 5856 KiB | ||||
26 | Wrong answer | 43ms | 8876 KiB | ||||
27 | Wrong answer | 43ms | 8908 KiB | ||||
28 | Time limit exceeded | 2.059s | 4684 KiB | ||||
29 | Time limit exceeded | 2.075s | 4840 KiB | ||||
30 | Time limit exceeded | 2.063s | 3804 KiB | ||||
31 | Time limit exceeded | 2.063s | 3576 KiB | ||||
subtask5 | 0/40 | ||||||
32 | Time limit exceeded | 2.059s | 3844 KiB | ||||
33 | Time limit exceeded | 2.061s | 4408 KiB | ||||
34 | Time limit exceeded | 2.063s | 5172 KiB | ||||
35 | Time limit exceeded | 2.069s | 5940 KiB | ||||
36 | Time limit exceeded | 2.075s | 6040 KiB | ||||
37 | Time limit exceeded | 2.075s | 6040 KiB | ||||
38 | Time limit exceeded | 2.068s | 4956 KiB | ||||
39 | Time limit exceeded | 2.059s | 6300 KiB | ||||
40 | Time limit exceeded | 2.063s | 4708 KiB | ||||
41 | Time limit exceeded | 2.059s | 4532 KiB |