40212023-03-09 09:03:58Error42Videójátékcpp17Wrong answer 0/1002.076s6572 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>

using namespace std;
using ll= long long;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t,n;
    cin>>t>>n;
    vector<pair<int,int>> me;
    vector<pair<int,int>> hu;
    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;
        hu.push_back(make_pair(x,y));
    }
    int ans=0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if(me[i].first+t==hu[j].first)
            {
                if(hu[j].second<me[i].second)
                {
                    ans+=hu[j].second-hu[j].first+1;
                }
                else{
                    ans+=me[i].second-hu[j].first+1;
                }
            }
            if(me[i].first<=hu[j].first && me[i].first+t>hu[j].first)
            {
                if(me[i].second<hu[j].second)
                {
                    ans+=me[i].second-hu[j].first+1;
                }
                else{
                    ans+=hu[j].second-hu[j].first+1;
                }
            }
            if(hu[j].first<=me[i].first && hu[j].second>me[i].first)
            {
                if(me[i].second<hu[j].second)
                {
                    ans+=me[i].second-me[i].first+1;
                }
                else{
                    ans+=hu[j].second-me[i].first+1;
                }
            }
            if(me[i].second==hu[j].first && me[i].second<=me[i].first+t)
            {
                ans++;
            }
            if(me[i].first==hu[j].second)
            {
                ans++;
            }
        }
        
    }
    cout<<ans;
}
/*
1
2
1 3
7 8
2
3 7
9 10
*/
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2024 KiB
subtask20/10
3Accepted3ms2228 KiB
4Accepted2ms2344 KiB
5Wrong answer2ms2540 KiB
6Accepted2ms2628 KiB
7Accepted2ms2756 KiB
8Accepted3ms2988 KiB
9Accepted2ms3064 KiB
10Accepted3ms3196 KiB
11Wrong answer3ms3392 KiB
subtask30/20
12Wrong answer2ms3480 KiB
13Accepted2ms3700 KiB
14Accepted3ms3924 KiB
15Wrong answer3ms4012 KiB
16Wrong answer3ms3916 KiB
17Accepted3ms3920 KiB
18Wrong answer4ms4184 KiB
19Wrong answer6ms4140 KiB
20Wrong answer4ms4468 KiB
21Wrong answer4ms4424 KiB
22Wrong answer3ms4420 KiB
subtask40/30
23Wrong answer246ms4872 KiB
24Time limit exceeded2.071s4364 KiB
25Time limit exceeded2.072s5688 KiB
26Time limit exceeded2.042s6148 KiB
27Time limit exceeded2.075s6432 KiB
28Time limit exceeded2.068s5120 KiB
29Wrong answer120ms5100 KiB
30Wrong answer109ms5096 KiB
31Wrong answer32ms4908 KiB
subtask50/40
32Wrong answer246ms5540 KiB
33Time limit exceeded2.072s5128 KiB
34Time limit exceeded2.072s5732 KiB
35Time limit exceeded2.072s6460 KiB
36Time limit exceeded2.061s6572 KiB
37Time limit exceeded2.039s6556 KiB
38Time limit exceeded2.052s5476 KiB
39Time limit exceeded2.068s6504 KiB
40Wrong answer885ms6264 KiB
41Time limit exceeded2.076s5100 KiB