140832025-01-09 18:23:25zhuyiÁruszállítás üres szakaszaicpp17Runtime error 4/50101ms32000 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    int n, m; cin >> n >> m;
    vector <pair <int,int>> A(m+1);
    for(int i = 1; i <= m; i++) cin >> A[i].first >> A[i].second;
    vector <vector <bool>> S(m+1, vector <bool>(n+1, false));
    for(int i = 1; i <= m; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if(S[i-1][j]) S[i][j]= true;
            else if(j <= A[i].second && j >= A[i].first) S[i][j] = true;
        }
    }
    int ans = 0;
    bool start = false;
    for(int i = 1; i <= n; i++)
    {
        if(!start && !S[m][i]) start = true;
        else if(start && S[m][i]) ans++;
    }
    cout << ans;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/01ms316 KiB
2Runtime error0/0101ms32000 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms508 KiB
11Wrong answer0/27ms780 KiB
12Wrong answer0/275ms4920 KiB
13Runtime error0/339ms32000 KiB
14Runtime error0/332ms32000 KiB
15Runtime error0/339ms32000 KiB
16Runtime error0/383ms32000 KiB
17Runtime error0/382ms32000 KiB
18Runtime error0/398ms32000 KiB
19Runtime error0/332ms32000 KiB
20Runtime error0/341ms32000 KiB
21Runtime error0/390ms32000 KiB
22Runtime error0/394ms32000 KiB