답안 #1031095

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031095 2024-07-22T14:46:24 Z Abito Fire (BOI24_fire) C++17
40 / 100
2000 ms 7248 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
//#define int long long
#define ll long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
const int N=2e5+5;
int L[N],R[N],n,m;
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n>>m;int ans=INT_MAX;
    for (int i=1;i<=n;i++) cin>>L[i]>>R[i];
    for (int k=1;k<=n;k++){
        int x=L[k];
        //cout<<x<<endl;
        vector<pair<int,int>> a;
        vector<int> p(n);
        for (int i=1;i<=n;i++){
            int l=(L[i]-x+m)%m,r=(R[i]-x+m)%m;
            //cout<<l<<' '<<r<<endl;
            if (l>r) r=m-1;
            a.pb({l,r});
        }
        sort(a.begin(),a.end());
        a.pb({m-1,m-1});
        /*for (auto u:a) cout<<u.F<<' ';cout<<endl;
        for (auto u:a) cout<<u.S<<' ';cout<<endl;
        cout<<endl;*/
        p[0]=a[0].S;
        for (int i=1;i<n;i++) p[i]=max(p[i-1],a[i].S);
        int cur=0,ansx=0;
        for (int i=0;i<=n;i++){
            if (a[i].F<=cur) continue;
            ansx++;
            cur=p[i-1];
            if (a[i].F>cur){
                ansx=INT_MAX;
                break;
            }
        }
        if (cur!=m-1) ansx=INT_MAX;
        ans=min(ans,ansx);
    }
    if (ans==INT_MAX) ans=-1;
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 464 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 464 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 5 ms 484 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 4 ms 484 KB Output is correct
29 Correct 4 ms 344 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 4 ms 344 KB Output is correct
33 Correct 4 ms 348 KB Output is correct
34 Correct 6 ms 348 KB Output is correct
35 Correct 4 ms 484 KB Output is correct
36 Correct 5 ms 348 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 464 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 5 ms 484 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 4 ms 484 KB Output is correct
29 Correct 4 ms 344 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 4 ms 344 KB Output is correct
33 Correct 4 ms 348 KB Output is correct
34 Correct 6 ms 348 KB Output is correct
35 Correct 4 ms 484 KB Output is correct
36 Correct 5 ms 348 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 5 ms 344 KB Output is correct
39 Correct 1453 ms 604 KB Output is correct
40 Correct 1464 ms 712 KB Output is correct
41 Correct 1499 ms 604 KB Output is correct
42 Correct 1498 ms 672 KB Output is correct
43 Correct 1502 ms 700 KB Output is correct
44 Correct 1396 ms 852 KB Output is correct
45 Correct 1441 ms 712 KB Output is correct
46 Correct 1364 ms 720 KB Output is correct
47 Correct 1383 ms 712 KB Output is correct
48 Correct 1371 ms 712 KB Output is correct
49 Correct 727 ms 664 KB Output is correct
50 Correct 1395 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 464 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 1396 ms 600 KB Output is correct
16 Correct 1440 ms 672 KB Output is correct
17 Correct 1428 ms 696 KB Output is correct
18 Correct 1530 ms 712 KB Output is correct
19 Correct 1440 ms 740 KB Output is correct
20 Execution timed out 2068 ms 7248 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 4 ms 604 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 5 ms 464 KB Output is correct
12 Correct 1441 ms 604 KB Output is correct
13 Correct 1392 ms 680 KB Output is correct
14 Correct 1391 ms 676 KB Output is correct
15 Execution timed out 2001 ms 7236 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 464 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 5 ms 484 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 4 ms 484 KB Output is correct
29 Correct 4 ms 344 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 4 ms 344 KB Output is correct
33 Correct 4 ms 348 KB Output is correct
34 Correct 6 ms 348 KB Output is correct
35 Correct 4 ms 484 KB Output is correct
36 Correct 5 ms 348 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 5 ms 344 KB Output is correct
39 Correct 1453 ms 604 KB Output is correct
40 Correct 1464 ms 712 KB Output is correct
41 Correct 1499 ms 604 KB Output is correct
42 Correct 1498 ms 672 KB Output is correct
43 Correct 1502 ms 700 KB Output is correct
44 Correct 1396 ms 852 KB Output is correct
45 Correct 1441 ms 712 KB Output is correct
46 Correct 1364 ms 720 KB Output is correct
47 Correct 1383 ms 712 KB Output is correct
48 Correct 1371 ms 712 KB Output is correct
49 Correct 727 ms 664 KB Output is correct
50 Correct 1395 ms 672 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 4 ms 348 KB Output is correct
60 Correct 4 ms 464 KB Output is correct
61 Correct 4 ms 348 KB Output is correct
62 Correct 4 ms 348 KB Output is correct
63 Correct 4 ms 348 KB Output is correct
64 Correct 4 ms 344 KB Output is correct
65 Correct 1396 ms 600 KB Output is correct
66 Correct 1440 ms 672 KB Output is correct
67 Correct 1428 ms 696 KB Output is correct
68 Correct 1530 ms 712 KB Output is correct
69 Correct 1440 ms 740 KB Output is correct
70 Execution timed out 2068 ms 7248 KB Time limit exceeded
71 Halted 0 ms 0 KB -