6520 | 2023-12-06 09:35:16 | EsVagy | Videójáték | cpp17 | Wrong answer 10/100 | 180ms | 9040 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 + 1;
friendBreakIndex++;
}
else
{
breakIndex++;
friendBreakIndex++;
}
}
cout << sum;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1688 KiB | ||||
2 | Accepted | 3ms | 1844 KiB | ||||
subtask2 | 10/10 | ||||||
3 | Accepted | 3ms | 2092 KiB | ||||
4 | Accepted | 3ms | 2180 KiB | ||||
5 | Accepted | 3ms | 2312 KiB | ||||
6 | Accepted | 3ms | 2548 KiB | ||||
7 | Accepted | 3ms | 2692 KiB | ||||
8 | Accepted | 3ms | 2944 KiB | ||||
9 | Accepted | 3ms | 3000 KiB | ||||
10 | Accepted | 3ms | 3132 KiB | ||||
11 | Accepted | 3ms | 3216 KiB | ||||
subtask3 | 0/20 | ||||||
12 | Accepted | 3ms | 3220 KiB | ||||
13 | Accepted | 3ms | 3340 KiB | ||||
14 | Accepted | 3ms | 3396 KiB | ||||
15 | Accepted | 3ms | 3544 KiB | ||||
16 | Accepted | 3ms | 3656 KiB | ||||
17 | Accepted | 4ms | 3860 KiB | ||||
18 | Accepted | 4ms | 3972 KiB | ||||
19 | Accepted | 4ms | 3972 KiB | ||||
20 | Wrong answer | 4ms | 4020 KiB | ||||
21 | Wrong answer | 3ms | 3980 KiB | ||||
22 | Wrong answer | 3ms | 4024 KiB | ||||
subtask4 | 0/30 | ||||||
23 | Accepted | 16ms | 4580 KiB | ||||
24 | Accepted | 50ms | 5492 KiB | ||||
25 | Accepted | 123ms | 8556 KiB | ||||
26 | Accepted | 136ms | 8540 KiB | ||||
27 | Accepted | 136ms | 8540 KiB | ||||
28 | Accepted | 54ms | 5956 KiB | ||||
29 | Wrong answer | 10ms | 4400 KiB | ||||
30 | Wrong answer | 10ms | 4468 KiB | ||||
31 | Accepted | 7ms | 4548 KiB | ||||
subtask5 | 0/40 | ||||||
32 | Wrong answer | 17ms | 5172 KiB | ||||
33 | Accepted | 59ms | 6116 KiB | ||||
34 | Accepted | 112ms | 7416 KiB | ||||
35 | Accepted | 159ms | 8984 KiB | ||||
36 | Accepted | 180ms | 8984 KiB | ||||
37 | Accepted | 180ms | 9040 KiB | ||||
38 | Wrong answer | 93ms | 7016 KiB | ||||
39 | Wrong answer | 112ms | 8452 KiB | ||||
40 | Accepted | 28ms | 5488 KiB | ||||
41 | Wrong answer | 43ms | 5672 KiB |