QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#562918 | #3944. Alehouse | WeaRD276 | WA | 0ms | 3812kb | C++20 | 2.2kb | 2024-09-13 22:56:23 | 2024-09-13 22:56:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<long long, long long> pll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<long long, long long> > vpll;
typedef set<int> si;
typedef set<long long> sll;
typedef map<int, int> mii;
typedef map<long long, long long> mll;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
constexpr int INF = 1e9 + 47;
constexpr long long LINF = (ll) 1e18 + 4747;
constexpr int MOD = 998244353;
constexpr int N = 1e5 + 47;
int solve()
{
int n;
ll k;
if (!(cin >> n >> k))
return 1;
set<pair<ll, bool>> events;
FOR (i, 0, n)
{
int x, y;
cin >> x >> y;
events.insert(MP(x, false));
events.insert(MP(y + k, true));
}
int ans = 0;
int cnt = 0;
for (auto it = events.begin(); it != events.end(); it++)
{
if ((*it).S)
--cnt;
else
++cnt;
ans = max(ans, cnt);
}
cout << ans << '\n';
return 0;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
input:
6 2 0 2 1 8 5 9 2 4 7 8 10 10
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
10 1 7 31 28 30 0 28 13 24 27 38 1 24 8 36 6 31 4 16 14 17
output:
8
result:
ok single line: '8'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3608kb
input:
10 2 28 32 25 32 5 23 2 37 10 27 16 38 10 19 23 34 3 5 13 38
output:
6
result:
wrong answer 1st lines differ - expected: '7', found: '6'