//#pragma GCC optimize("O3")
//#pragma GCC target("tune=native")
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include "teams.h"
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<fstream>
#include<algorithm>
#include <iomanip>
#include<map>
#include <set>
#include <unordered_map>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <cstdint>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define shit short int
#define ll long long
//#define int ll
#define For(i, n) for(int i = 0; i < (int)n; i++)
#define ffor(i, a, n) for(int i = (int)a; i < (int)n; i++)
#define rfor(i, n) for(int i = (int)n; i >= (int)0; i--)
#define rffor(i, a, n) for(int i = (int)n; i >= (int)a; i--)
#define vec vector
#define ff first
#define ss second
#define pb push_back
#define pii pair<int, int>
#define NEK 2000000000
#define mod 1000000007
#define mod2 1000000009
#define rsz resize
#define prv1 47
#define prv2 43
#define D 8
#define trav(a,x) for (auto& a: x)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(x) (x).begin(), (x).end()
#define sig 0.0000001
using namespace std;
//using namespace __gnu_pbds;
//template <typename T1, typename T2>
//using indexed_set = tree<pair<T1, T2>, null_type, less<pair<T1, T2>>, rb_tree_tag, tree_order_statistics_node_update>;
int a[100000];
int b[100000];
int n;
void init(int n2, int a2[], int b2[]) {
n = n2;
vec<pii> p;
For(i, n) {
p.push_back({ a2[i], b2[i] });
}
sort(all(p));
For(i, n) a[i] = p[i].ff, b[i] = p[i].ss;
return;
}
int can(int m, int k[]) {
priority_queue<int> q;
sort(k, k + m);
int som = 0;
For(i, m) {
while (som < n && a[som] <= k[i]) {
q.push(b[som] * (-1));
som++;
}
while (!q.empty() && (q.top() * (-1)) < k[i]) {
q.pop();
}
For(j, k[i]) {
if (q.empty()) return 0;
q.pop();
}
}
return 1;
}
/*
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n; cin >> n;
int a2[100], b2[100];
For(i, n) cin >> a2[i];
For(i, n) cin >> b2[i];
init(n, a2, b2);
int q; cin >> q;
For(i, q) {
int m; cin >> m;
int k[100];
For(i, m) cin >> k[i];
cout << can(m, k) << '\n';
}
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |