| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1353329 | HossamHero7 | Fire (BOI24_fire) | C++20 | 2094 ms | 3540 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
int n,m;
cin>>n>>m;
vector<pair<int,int>> v(n);
for(auto &[a,b] : v){
cin>>a>>b;
if(a > b) b += m;
}
sort(v.begin(),v.end());
int ans = 1e9;
for(int i=0;i<n;i++){
vector<pair<int,int>> tmp = v;
int l = v[i].first , r = v[i].second;
int tar = v[i].first + m - 1;
int cnt = 1;
for(auto &[x,y] : v){
if(x < l) x += m , y += m;
}
sort(v.begin(),v.end());
int pt = 0;
while(r < tar){
int mx = 0;
while(pt < n && v[pt].first <= r) mx = max(mx , v[pt].second) , pt ++;
if(mx <= r) {
v = tmp;
goto gt;
}
cnt ++;
r = max(mx , r);
}
ans = min(ans , cnt);
v = tmp;
gt:continue;
}
cout<<(ans == 1e9 ? -1 : ans)<<endl;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
