제출 #1042583

#제출 시각아이디문제언어결과실행 시간메모리
1042583Theo830Fire (BOI24_fire)C++17
13 / 100
45 ms9052 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,m;
    cin>>n>>m;
    vector<ii>ex;
    ll mini = m+5;
    f(i,0,n){
        ll s,e;
        cin>>s>>e;
        if(s < e){
            ex.pb(ii(s,e));
        }
        else{
            mini = min(mini,s);
        }
    }
    sort(all(ex));
    ll ans = 1;
    ll pos = 0;
    ll cur = 0;
    while(pos < ex.size() && cur < mini){
        ll go = cur;
        while(pos < ex.size() && ex[pos].F <= cur){
            go = max(go,ex[pos].S);
            pos++;
        }
        ans++;
        if(cur == go){
            break;
        }
        cur = go;
    }
    if(cur < mini){
        ans = -1;
    }
    cout<<ans<<"\n";
}
/*
4 10
0 2
1 3
2 4
3 0
*/

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:46:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     while(pos < ex.size() && cur < mini){
      |           ~~~~^~~~~~~~~~~
Main.cpp:48:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         while(pos < ex.size() && ex[pos].F <= cur){
      |               ~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...