131212025-01-06 17:03:55ubormaciÁruszállítás üres szakaszaicpp17Wrong answer 2/5052ms4568 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <array>
#include <string>
#include <cstdio>
#include <iterator>
#include <unordered_set>
#include <cstdint>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <fstream>
using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

/*

notes:

int64_t
stoi(string s) -> string to int
to_string() -> int (or else) to string

vector declaration:
vector<ll> v(n, 0)
vector<vector<ll>> v(n, vector<ll>(n, 0));

{if statement} ? {truth value} : {false value}

set lower bound/upper bound:
 	// . . . m1 . . . d . . . . m2
    auto m1_it = b.lower_bound(d);
    advance(m1_it, -1);
    m1 = *m1_it;
	m2 = *b.upper_bound(d);

#ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif

constexpr auto lcm(auto x, auto... xs)
{
	return ((x = std::lcm(x, xs)), ...);
}

std::gcd(int a, int b)

*/

typedef long long ll;

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<pair<ll,ll>> q;

    ll s = 0;
    ll in = 0;

    for(ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        q.push_back({a, -1});
        q.push_back({b, 1});
    }

    sort(q.begin(), q.end());
    for(ll i = 0; i < q.size(); i++) {
        in -= q[i].second;
        if(in == 0 && q[i].first != n) {
            s++;
        }
    }

    cout << s;

}

int main()
{
	std::ios_base::sync_with_stdio(false);

	solve();

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/01ms316 KiB
2Wrong answer0/052ms4512 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/21ms316 KiB
12Wrong answer0/21ms316 KiB
13Wrong answer0/34ms656 KiB
14Wrong answer0/34ms820 KiB
15Wrong answer0/33ms820 KiB
16Wrong answer0/335ms4568 KiB
17Wrong answer0/337ms4536 KiB
18Wrong answer0/343ms4484 KiB
19Wrong answer0/34ms948 KiB
20Wrong answer0/34ms948 KiB
21Wrong answer0/348ms4520 KiB
22Wrong answer0/348ms4516 KiB