Submission #1042583

# Submission time Handle Problem Language Result Execution time Memory
1042583 2024-08-03T07:44:26 Z Theo830 Fire (BOI24_fire) C++17
13 / 100
45 ms 9052 KB
#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
*/

Compilation message

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 time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 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 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 584 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 18 ms 3208 KB Output is correct
21 Correct 41 ms 8016 KB Output is correct
22 Correct 37 ms 9052 KB Output is correct
23 Correct 34 ms 7380 KB Output is correct
24 Correct 45 ms 8660 KB Output is correct
25 Correct 34 ms 8100 KB Output is correct
26 Correct 37 ms 7880 KB Output is correct
27 Correct 35 ms 8048 KB Output is correct
28 Correct 43 ms 8916 KB Output is correct
# 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 464 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 14 ms 3288 KB Output is correct
16 Correct 33 ms 6824 KB Output is correct
17 Incorrect 44 ms 8344 KB Output isn't correct
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -