41342023-03-15 12:08:471478Kikötők (35 pont)cpp17Accepted 35/3521ms4888 KiB
#include <bits/stdc++.h>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int main()
{
    fast_cin();
    //ifstream cin("in.txt");

    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<int> db(n + 2);
    for (int i = 1; i <= m; i++)
    {
        int a;
        cin >> a;
        int b;
        cin >> b;
        db[a]++;
        db[b + 1]--;
        db[a + 1]++;
        db[b]--;
    }
    int maxi = 0;
    int maxind;
    int a = 0;
    for (int i = 1; i <= n; i++)
    {
        a += db[i];
        if (a > maxi)
        {
            maxi = a;
            maxind = i;
        }
    }
    cout << maxind << " " << maxi;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1832 KiB
2Accepted0/021ms2880 KiB
3Accepted1/13ms2228 KiB
4Accepted1/13ms2444 KiB
5Accepted1/12ms2532 KiB
6Accepted1/13ms2656 KiB
7Accepted1/13ms2740 KiB
8Accepted2/23ms2748 KiB
9Accepted2/23ms2880 KiB
10Accepted2/23ms2960 KiB
11Accepted2/23ms3304 KiB
12Accepted2/23ms3396 KiB
13Accepted2/23ms3308 KiB
14Accepted2/24ms3600 KiB
15Accepted2/24ms3776 KiB
16Accepted2/221ms3648 KiB
17Accepted2/221ms3792 KiB
18Accepted2/24ms3776 KiB
19Accepted2/24ms4444 KiB
20Accepted2/219ms4520 KiB
21Accepted2/221ms4888 KiB
22Accepted2/221ms4848 KiB