| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1018932 | beaconmc | Fire (BOI24_fire) | C++14 | 2097 ms | 11932 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
vector<vector<ll>> normal;
vector<vector<ll>> overlap;
int solve(ll lo, ll hi){
ll ans = 0;
ll cur = 0;
while (lo < hi){
ll maxi = 0;
while (cur < normal.size()){
if (normal[cur][0] > lo) break;
maxi = max(maxi, normal[cur][1]);
cur++;
}
if (maxi > lo) ans += 1, lo = maxi;
else return -1;
}
return ans;
}
int main(){
ll n,m;
cin >> n >> m;
FOR(i,0,n){
ll a,b;
cin >> a >> b;
if (a<b) normal.push_back({a,b});
else overlap.push_back({b,a});
}
sort(normal.begin(), normal.end());
ll ans = -1;
//check twice
ll left = 0, right = m;
for (auto&i : overlap) left = max(left, i[0]), right = min(right, i[1]);
if (solve(left, right) != -1) ans = solve(left, right)+2;
for (auto&i : overlap){
ans = min( ans, (ll)solve(i[0], i[1]) + 1);
}
cout << ans;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
