40202023-03-09 09:01:09Error42Videójátékcpp17Wrong answer 0/1002.079s6124 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
1Accepted3ms1824 KiB
2Accepted3ms2060 KiB
subtask20/10
3Accepted3ms2548 KiB
4Accepted3ms2616 KiB
5Wrong answer3ms2696 KiB
6Accepted2ms2764 KiB
7Accepted3ms2996 KiB
8Accepted2ms3104 KiB
9Accepted2ms2972 KiB
10Accepted3ms3100 KiB
11Wrong answer3ms3308 KiB
subtask30/20
12Wrong answer2ms3396 KiB
13Accepted3ms3516 KiB
14Accepted2ms3612 KiB
15Wrong answer3ms3736 KiB
16Wrong answer3ms3952 KiB
17Accepted3ms4060 KiB
18Wrong answer4ms4324 KiB
19Wrong answer6ms4396 KiB
20Wrong answer4ms4448 KiB
21Wrong answer4ms4524 KiB
22Wrong answer3ms4512 KiB
subtask40/30
23Wrong answer272ms4940 KiB
24Time limit exceeded2.055s4408 KiB
25Time limit exceeded2.079s5732 KiB
26Time limit exceeded2.069s5884 KiB
27Time limit exceeded2.052s6000 KiB
28Time limit exceeded2.075s4796 KiB
29Wrong answer133ms4700 KiB
30Wrong answer120ms4748 KiB
31Wrong answer37ms4744 KiB
subtask50/40
32Wrong answer270ms5012 KiB
33Time limit exceeded2.072s4648 KiB
34Time limit exceeded2.063s5356 KiB
35Time limit exceeded2.063s6124 KiB
36Time limit exceeded2.079s6060 KiB
37Time limit exceeded2.065s6052 KiB
38Time limit exceeded2.068s5048 KiB
39Time limit exceeded2.061s5932 KiB
40Wrong answer994ms5620 KiB
41Time limit exceeded2.053s4372 KiB