6519 | 2023-12-06 09:31:52 | EsVagy | Videójáték | cpp17 | Wrong answer 10/100 | 181ms | 37344 KiB |
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <climits>
#include <queue>
#include <fstream>
#include <sstream>
#include <math.h>
using namespace std;
int main()
{
int t;
int n, m;
vector<pair<int, int>> breaks;
vector<pair<int, int>> friendBreaks;
cin >> t;
cin >> n;
for (int i = 0; i < n; i++)
{
int first, second;
cin >> first >> second;
breaks.push_back(pair<int, int>(first, second));
}
cin >> m;
for (int i = 0; i < m; i++)
{
int first, second;
cin >> first >> second;
friendBreaks.push_back(pair<int, int>(first, second));
}
int sum = 0;
int breakIndex = 0;
int friendBreakIndex = 0;
while (breakIndex < breaks.size() && friendBreakIndex < friendBreaks.size())
{
pair<int, int> match = pair<int, int>(max(breaks[breakIndex].first, friendBreaks[friendBreakIndex].first), min(breaks[breakIndex].second, friendBreaks[friendBreakIndex].second));
if (match.first > match.second)
{
if (breaks[breakIndex].first > friendBreaks[friendBreakIndex].second)
{
friendBreakIndex++;
continue;
}
else
{
breakIndex++;
continue;
}
}
if (match.first >= breaks[breakIndex].first + t)
{
breakIndex++;
continue;
}
sum += match.second - match.first + 1;
if (breaks[breakIndex].second < friendBreaks[friendBreakIndex].second)
{
breakIndex++;
}
else if (breaks[breakIndex].second > friendBreaks[friendBreakIndex].second)
{
breaks[breakIndex].first = friendBreaks[friendBreakIndex].second;
friendBreakIndex++;
}
else
{
breakIndex++;
friendBreakIndex++;
}
}
cout << sum;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1816 KiB | ||||
2 | Accepted | 3ms | 2060 KiB | ||||
subtask2 | 10/10 | ||||||
3 | Accepted | 3ms | 2300 KiB | ||||
4 | Accepted | 3ms | 2544 KiB | ||||
5 | Accepted | 3ms | 2708 KiB | ||||
6 | Accepted | 3ms | 2956 KiB | ||||
7 | Accepted | 3ms | 3164 KiB | ||||
8 | Accepted | 3ms | 3360 KiB | ||||
9 | Accepted | 3ms | 3464 KiB | ||||
10 | Accepted | 3ms | 3596 KiB | ||||
11 | Accepted | 3ms | 3524 KiB | ||||
subtask3 | 0/20 | ||||||
12 | Accepted | 3ms | 3632 KiB | ||||
13 | Accepted | 3ms | 3876 KiB | ||||
14 | Accepted | 3ms | 3940 KiB | ||||
15 | Accepted | 3ms | 3944 KiB | ||||
16 | Accepted | 3ms | 4064 KiB | ||||
17 | Accepted | 4ms | 4232 KiB | ||||
18 | Accepted | 4ms | 4344 KiB | ||||
19 | Accepted | 4ms | 4328 KiB | ||||
20 | Wrong answer | 4ms | 4380 KiB | ||||
21 | Wrong answer | 4ms | 4416 KiB | ||||
22 | Wrong answer | 3ms | 4440 KiB | ||||
subtask4 | 0/30 | ||||||
23 | Accepted | 14ms | 5148 KiB | ||||
24 | Accepted | 50ms | 7036 KiB | ||||
25 | Accepted | 126ms | 12116 KiB | ||||
26 | Accepted | 143ms | 14704 KiB | ||||
27 | Accepted | 137ms | 17244 KiB | ||||
28 | Accepted | 54ms | 15696 KiB | ||||
29 | Wrong answer | 12ms | 14460 KiB | ||||
30 | Wrong answer | 10ms | 14576 KiB | ||||
31 | Accepted | 7ms | 14616 KiB | ||||
subtask5 | 0/40 | ||||||
32 | Wrong answer | 17ms | 15140 KiB | ||||
33 | Accepted | 61ms | 17328 KiB | ||||
34 | Accepted | 112ms | 21108 KiB | ||||
35 | Accepted | 159ms | 26004 KiB | ||||
36 | Accepted | 180ms | 29824 KiB | ||||
37 | Accepted | 181ms | 33364 KiB | ||||
38 | Wrong answer | 94ms | 33380 KiB | ||||
39 | Wrong answer | 114ms | 37344 KiB | ||||
40 | Accepted | 29ms | 34844 KiB | ||||
41 | Wrong answer | 45ms | 35756 KiB |