답안 #1083771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083771 2024-09-04T05:54:00 Z vjudge1 Fire (BOI24_fire) C++17
14 / 100
95 ms 464 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define for1(i,x,n) for(int i=x;i<=n;i++)
#define for2(i,x,n) for(int i=x;i>=n;i--)
#define int ll

typedef long long ll;
typedef pair<int,int> pii;

const ll maxn=2e5+69;
const ll mod=1e9+7;
const ll inf=1e18;
int n,m;
pii a[maxn];
void sol()
{
    cin >> n>> m;
    for1(i,1,n)
    {
        cin >>a[i].fi>> a[i].se;
        if (a[i].se<a[i].fi) a[i].se+=m;
//        cerr<<n<< "adsa\n";
    }
    sort(a+1,a+1+n);
    int res=inf;
    for1(mask,1,(1<<n)-1)
    {
        int l=-1,r=-1;
        bool flag=1;
        for1(i,1,n)
        {
            if (mask>>(i-1)&1)
            {
                if (l==-1) l=a[i].fi;
                if (r!=-1 && r<a[i].fi)
                {
                    flag=0;
                    break;
                }
                r=max(r,a[i].se);
            }
            if (flag && r-l>=m)
            {
                res=min(res,(ll)__builtin_popcount(mask));
            }
        }
    }
    if (res==inf) cout << "-1";
    else cout << res;

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("fire.inp","r",stdin);
//    freopen("fire.ans","w",stdout);
    int t=1;//cin >> t;
    while (t--)
    {
        sol();
    }
}




# 결과 실행 시간 메모리 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 1 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 24 ms 464 KB Output is correct
9 Correct 51 ms 436 KB Output is correct
10 Correct 16 ms 348 KB Output is correct
11 Correct 35 ms 348 KB Output is correct
12 Correct 15 ms 348 KB Output is correct
13 Correct 16 ms 348 KB Output is correct
14 Correct 15 ms 348 KB Output is correct
15 Correct 94 ms 348 KB Output is correct
16 Correct 65 ms 348 KB Output is correct
17 Correct 14 ms 344 KB Output is correct
18 Correct 70 ms 344 KB Output is correct
19 Correct 40 ms 344 KB Output is correct
20 Correct 14 ms 348 KB Output is correct
21 Correct 33 ms 348 KB Output is correct
22 Correct 29 ms 344 KB Output is correct
23 Correct 11 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 1 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 24 ms 464 KB Output is correct
9 Correct 51 ms 436 KB Output is correct
10 Correct 16 ms 348 KB Output is correct
11 Correct 35 ms 348 KB Output is correct
12 Correct 15 ms 348 KB Output is correct
13 Correct 16 ms 348 KB Output is correct
14 Correct 15 ms 348 KB Output is correct
15 Correct 94 ms 348 KB Output is correct
16 Correct 65 ms 348 KB Output is correct
17 Correct 14 ms 344 KB Output is correct
18 Correct 70 ms 344 KB Output is correct
19 Correct 40 ms 344 KB Output is correct
20 Correct 14 ms 348 KB Output is correct
21 Correct 33 ms 348 KB Output is correct
22 Correct 29 ms 344 KB Output is correct
23 Correct 11 ms 348 KB Output is correct
24 Incorrect 20 ms 344 KB Output isn't correct
25 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 1 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 24 ms 464 KB Output is correct
9 Correct 51 ms 436 KB Output is correct
10 Correct 16 ms 348 KB Output is correct
11 Correct 35 ms 348 KB Output is correct
12 Correct 15 ms 348 KB Output is correct
13 Correct 16 ms 348 KB Output is correct
14 Correct 15 ms 348 KB Output is correct
15 Correct 94 ms 348 KB Output is correct
16 Correct 65 ms 348 KB Output is correct
17 Correct 14 ms 344 KB Output is correct
18 Correct 70 ms 344 KB Output is correct
19 Correct 40 ms 344 KB Output is correct
20 Correct 14 ms 348 KB Output is correct
21 Correct 33 ms 348 KB Output is correct
22 Correct 29 ms 344 KB Output is correct
23 Correct 11 ms 348 KB Output is correct
24 Incorrect 20 ms 344 KB Output isn't correct
25 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 15 ms 348 KB Output is correct
4 Correct 95 ms 444 KB Output is correct
5 Correct 75 ms 344 KB Output is correct
6 Correct 18 ms 344 KB Output is correct
7 Correct 70 ms 440 KB Output is correct
8 Correct 34 ms 344 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 54 ms 436 KB Output is correct
5 Correct 15 ms 464 KB Output is correct
6 Correct 14 ms 344 KB Output is correct
7 Correct 71 ms 452 KB Output is correct
8 Incorrect 0 ms 344 KB Output isn't correct
9 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 1 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 24 ms 464 KB Output is correct
9 Correct 51 ms 436 KB Output is correct
10 Correct 16 ms 348 KB Output is correct
11 Correct 35 ms 348 KB Output is correct
12 Correct 15 ms 348 KB Output is correct
13 Correct 16 ms 348 KB Output is correct
14 Correct 15 ms 348 KB Output is correct
15 Correct 94 ms 348 KB Output is correct
16 Correct 65 ms 348 KB Output is correct
17 Correct 14 ms 344 KB Output is correct
18 Correct 70 ms 344 KB Output is correct
19 Correct 40 ms 344 KB Output is correct
20 Correct 14 ms 348 KB Output is correct
21 Correct 33 ms 348 KB Output is correct
22 Correct 29 ms 344 KB Output is correct
23 Correct 11 ms 348 KB Output is correct
24 Incorrect 20 ms 344 KB Output isn't correct
25 Halted 0 ms 0 KB -