Submission #1031090

# Submission time Handle Problem Language Result Execution time Memory
1031090 2024-07-22T14:43:36 Z Abito Fire (BOI24_fire) C++17
0 / 100
1 ms 348 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({INT_MAX,INT_MAX});
        /*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 (cur!=m-1) ansx=INT_MAX;
        ans=min(ans,ansx);
    }
    if (ans==INT_MAX) ans=-1;
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -