# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1027983 | 2024-07-19T12:10:35 Z | Issa | Fire (BOI24_fire) | C++17 | 1 ms | 2396 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ent "\n" const int maxn = 3e5 + 100; const ll INF = (ll)1e18 + 100; const int inf = 1e9 + 100; const int MOD = 1e9 + 7; const int maxl = 350; const int P = 31; int n, m; pii a[maxn]; pii b[maxn]; int f(int i, int j){ if(j >= i) return j - i; return m + j - i; } void test(){ cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i].first >> a[i].second; } int ans = inf; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ b[j] = a[j]; if(a[j].first < a[i].first){ b[j].first += m; b[j].second += m; } else if(a[j].second < a[j].first){ b[j].second += m; } } sort(b + 1, b + n + 1, [](pii i, pii j){ if(i.first != j.first) return i < j; return i.second > j.second; }); vector<int> v; bool ok = 1; for(int i = n; i > 0; i--){ while(v.size() && b[v.back()].second <= b[i].second) v.pop_back(); while(v.size() > 1 && b[v[v.size()-2]].first <= b[i].second) v.pop_back(); if(v.size() && b[v.back()].first > b[i].second) ok = 0; v.push_back(i); } if(!ok) continue; int p = -1; while(p + 1 < v.size() && b[v[p+1]].second - b[v.back()].first >= m){ p++; } if(b[v[p+1]].second - b[v.back()].first >= m) ans = min(ans, (int)v.size() - p); } if(ans == inf) ans = -1; cout << ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; t = 1; while(t--) test(); cout << ent; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Incorrect | 1 ms | 2392 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |