text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
void func() {
int n;
cin >> n;
vector<int> arr(n), acop(n);
for (int i = 0; i < n; ++i) {
cin >> arr[i];
acop[i] = arr[i];
}
sort(acop.begin(), acop.end(), greater<int>());
int q;
cin >> q;
for (int i = 0; i < q; ++i) {
int k, pos, cnt = 0;
... |
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e9 + 5;
const double eps = 1e-7;
const double PI = acos(-1.0);
inline void debug_vi(vector<int> a) {
for (long long i = (long long)(0); i < (long long)(a.size()); i++)
cout << a[i] << " ";
}
inline void debug_vl... |
#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2, typename T3>
struct pair3 {
T1 first;
T2 second;
T3 third;
};
template <typename T1, typename T2, typename T3, typename T4>
struct pair4 {
T1 first;
T2 second;
T3 third;
T4 fourth;
};
const long long MOD = 1000000007;
const ... |
#include <bits/stdc++.h>
using namespace std;
struct eq {
long long si, f, s, r;
};
bool compare(eq a, eq b) {
if (a.f == b.f) return a.s < b.s;
return a.f < b.f;
}
bool comp(eq a, eq b) { return a.si < b.si; }
void solve() {
long long n;
cin >> n;
vector<pair<long long, long long> > v;
for (long long i =... |
#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<long long int, long long int> &a,
const pair<long long int, long long int> &b) {
if (a.first == b.first) {
return a.second < b.second;
}
return a.first > b.first;
}
int main() {
int n;
cin >> n;
vector<long long int> arr(n);
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
vector<long long> a(n), b(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
b[i] = a[i];
}
sort(a.begin(), a.end(), greater<long long>());
long long m;
cin >> m;
vector<long long>... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long ar[n];
long long br[n];
for (auto x = 0; x < n; x++) {
cin >> ar[x];
br[x] = ar[x];
}
sort(br, br + n);
long long m;
cin >> m;
while (m--) {
long long pos, k;
set<long long> s;
cin >> k >>... |
#include <bits/stdc++.h>
using namespace std;
signed main() {
long long n;
cin >> n;
vector<long long> v(n);
map<long long, vector<long long>> def;
for (long long i = 0; i < n; i++) {
cin >> v[i];
def[v[i]].push_back(i);
}
vector<long long> g;
for (auto p : def) {
long long a = p.first;
... |
#include <bits/stdc++.h>
using namespace std;
long long bin_pow(long long a, long long b) {
if (b == 0) return 1;
if (b % 2 == 0) {
long long t = bin_pow(a, b / 2);
return t * t % 1000000007;
} else
return a * bin_pow(a, b - 1) % 1000000007;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
... |
#include <bits/stdc++.h>
using namespace std;
vector<int> srr;
map<int, int> occ;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int arr[200], n, m, pj, k, fast = 1, last;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> arr[i];
srr.push_back(arr[i]);
}
sort(srr.begin(), srr.end(), greater<i... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, n, m, k;
cin >> n;
vector<int> v[n + 1];
vector<long long int> s;
for (int i = 0; i < n; i++) {
cin >> t;
v[n].push_back(t);
s.push_back(t);
}
sort(s.begin(), s.end());
int l = n - 1, x = 0, y;
while (l > 0) {
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> arr(n);
set<pair<int, int>> left;
for (int i = 0; i < arr.size(); i++) {
cin >> arr[i];
left.insert(make_pair(arr[i], i * -1));
}
int m;
cin >> m;
while (m--) {
int k, j;
cin >> k >> j;
j--;
... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long N = 1234567891, M = 31;
long long n, m, t, k, f, mi = 2e9, x, y, z, ma, x3, x2, y2, l, r, i, j, ans, vv,
a2[410000], d[410000], dp[810000];
strin... |
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
void ct(vector<int> &a) {
for (auto &i : a) cout << i << ' ';
cout << '\n';
}
void ct(vector<pair<int, int>> &a) {
for (auto &i : a) cout << i.first << ":" << i.second << ' ';
cout <... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
pair<int, int> a[112];
int main() {
ios_base::sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n; i++) {
int num;
cin >> num;
a[i] = {-num, i};
}
sort(a, a + n);
cin >> m;
for (int i = 1; i <= m; i++) {
int k, pos;
cin >> k >> po... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 9;
struct node {
int x, y;
} a[maxn];
int b[maxn];
bool cmp(node a, node b) { return a.x == b.x ? a.y < b.y : a.x > b.x; }
map<int, int> A;
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &a[i].x);
b[i] ... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100;
int arr[N];
multimap<int, int, greater<int>> l;
map<int, int> mp;
vector<int> ans[N];
int main() {
ios_base::sync_with_stdio();
cin.tie(0);
cout.tie(0);
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) scanf("%d", arr ... |
#include <bits/stdc++.h>
using namespace std;
int bsl(vector<pair<int, int>> &A, int val) {
int left = -1;
int right = (int)A.size();
while (right - left > 1) {
int mid = (left + right) / 2;
if (A[mid].first >= val) {
right = mid;
} else {
left = mid;
}
}
return right;
}
int bsr(ve... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, m, x, i, ma = 0;
cin >> n;
vector<pair<long long int, long long int>> v1;
for (i = 1; i <= n; i++) cin >> x, v1.push_back(make_pair(-x, i));
sort(v1.begin(), v1.end());
cin >> m;
while (m--) {
long long int k, pos, j = 0;
... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int inf = 1e9 + 7;
bool compA(pair<int, int> a, pair<int, int> b) {
if (a.first == b.first) return a.second < b.second;
return a.first > b.first;
}
bool comp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
void run() ... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const long long MOD = 1e9 + 7;
const long long mxN = 2e5 + 3;
bool cmp(pair<long long, long long> p1, pair<long long, long long> p2) {
if (p1.first > p2.first)
return true;
else if (p1.first == p2.firs... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
struct node {
int id;
int num;
};
node s[maxn];
int b[maxn];
int num[maxn];
bool cmp(node a, node b) {
if (a.num != b.num)
return a.num > b.num;
else
return a.id < b.id;
}
struct ask {
int id;
int L = 0;
int pos;
};
ask A[ma... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
mt19937 rnd(time(0));
const long long INF = 1e9;
struct Point {
Point() {
cin >> x;
cin >> y;
}
Point(long double x, long double y) : x(x), y(y) {}
long double x, y;
};
void solve() {
int n, m, k, pos;
cin >> n;
vector<int... |
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
const long long num = 1000000000;
bool check1(pair<long long, long long> a, pair<long long, long long> b) {
return a.first == b.first ? (a.second > b.second) : (a.first < b.first);
}
bool check2(pair<long long, long long> a, pair<long long, lon... |
#include <bits/stdc++.h>
using namespace std;
long long int powMod(long long int x, long long int y) {
long long int p = 1;
while (y) {
if (y % 2) {
p = (p * x) % 1000000007;
}
y /= 2;
x = (x * x) % 1000000007;
}
return p;
}
long long int invMod(long long int x) { return powMod(x, 10000000... |
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cer... |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e5 + 7;
const int inf = INT_MAX / 2;
const long long INF = LLONG_MAX / 3;
const int MOD = 1e9 + 7;
const double eps = 1e-6;
const string cars[] = {"🚗", "🚕", "🚙"};
signed main() {
cout <... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
bool cmp(pair<int, int> a, pair<int, int> b) {
if (a.first != b.first) return a.first > b.first;
return a.second < b.second;
}
bool cmp2(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int main() {
ios_base::sync_with_stdio(0);
cin.tie(... |
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long int, long long int> a,
pair<long long int, long long int> b) {
if (a.first != b.first)
return a.first < b.first;
else
return a.second > b.second;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
... |
#include <bits/stdc++.h>
using namespace std;
vector<long long int> graph[200007];
long long int visited[200007] = {0};
long long int mx = 0, cnt = 0;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n, m, i, j;
cin >> n;
long long int a[n + 10];
vector<pair<long long int, long lo... |
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
if (a.first != b.first) return a.first < b.first;
return a.second > b.second;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<pair<int, int>> a;
for (int i = 0; i < n; ++i) {
... |
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
using namespace std;
int a[1000], b[1000];
map<int, bool> mk;
int main() {
iostream::sync_with_stdio(0);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >>... |
#include <bits/stdc++.h>
using namespace std;
void solve();
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
template <typename T>
istream &operator>>(istream &in, vector<T> &ans) {
for (auto &d : ans) in >> d;
return in;
}
template <typename T>
ostream &operator<<(ostrea... |
#include <bits/stdc++.h>
using namespace std;
int a[101];
bool comp(pair<int, int> x, pair<int, int> y) {
if (x.first == y.first) {
return x.second < y.second;
}
return x.first > y.first;
}
bool comp2(pair<int, int> x, pair<int, int> y) { return x.second < y.second; }
int d[101][101];
int main() {
cin.sync_... |
#include <bits/stdc++.h>
using namespace std;
inline void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
map<int, vector<int> > mp;
for (int i = 0; i < n; ++i) {
mp[a[i]]... |
#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast")
using namespace std;
bool compare(pair<long long, long long> a, pair<long long, long long> b) {
if (a.first != b.first) {
return a.first > b.first;
} else {
return a.second < b.second;
}
}
int32_t main() {
long long n;
cin >> n;
long long arr[n... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<pair<int, int>> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i].first;
v[i].second = i + 1;
v[i].first *= -1;
}
sort(v.begin(), v.end());
int t;
cin >> t... |
#include <bits/stdc++.h>
using namespace std;
int dv(pair<int, int> p1, pair<int, int> p2) {
if (p1.first < p2.first) return 0;
if (p1.first > p2.first) return 1;
if (p1.second > p2.second) return 0;
return 1;
}
int main() {
int t, n, m, p, k, a, b, c, l, r;
cin >> n;
int A[n];
for (int i = 0; i < n; i+... |
#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> adj;
map<long, bool> vis, viss;
vector<long long> rnk, parent, sz;
int spf[1000000 + 1];
long long binpow(long long a, long long b, long long m) {
a %= m;
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a % m;
a = a * a % m;... |
#include <bits/stdc++.h>
using namespace std;
bool kmp(int a, int b) { return a < b; }
int main() {
int n, m;
int x = 0;
int y = 0;
int z = 0;
cin >> n;
int a[n];
int d[n][n];
int c[n];
int an[100003];
int k = 0;
int p = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
c[i] = 1;
}
cin >... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getrnd(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
template <typename T1, typename T2>
bool relax(T1... |
#include <bits/stdc++.h>
const int maxn = 1e5 + 5;
using namespace std;
int n, q;
struct node {
int x, y, z;
} a[maxn], b[maxn], c[maxn];
int tot = 1, ans[maxn];
bool tmp(const node &u, const node &v) {
if (u.x != v.x) return u.x > v.x;
return u.y < v.y;
}
bool cc(const node &u, const node &v) {
if (u.x != v.x)... |
#include <bits/stdc++.h>
using namespace std;
void Update(const long &);
long FindSum(const long &);
long N, M, K = 0;
vector<long> BIT;
int main() {
cin >> N;
vector<pair<long, long>> A(N + 1);
vector<long> X(N + 1);
for (long i = 1; i <= N; ++i) {
cin >> A[i].first;
A[i].second = i;
X[i] = A[i].fi... |
#include <bits/stdc++.h>
using namespace std;
vector<bool> sieve(long long n) {
vector<bool> prime(n + 1, true);
prime[0] = prime[1] = false;
for (long long i = 2; i <= n; ++i) {
if (prime[i] && (i * i) <= n)
for (long long j = i * i; j <= n; j += i) prime[j] = false;
}
return prime;
}
long long pow... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
c b, e;
};
template <class c>
rge<c> range(c i, c j) {
return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
template <class c>
... |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(20);
long long n = 0;
cin >> n;
deque<long long> posl(n);
for (auto& p : posl) cin >> p;
map<long long, long long> al;
for (auto& p : posl) al[p]++;
long long m = 0;
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int i, j, k, l, m, n;
cin >> n;
long long int a[n];
vector<long long int> v;
for (i = 0; i < n; i++) {
cin >> a[i];
v.push_back(a[i]);
}
sort(v.begin(), v.end());
long long int var;
cin >> var;
while (var--) {
cin >> k ... |
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
return a.first > b.first || a.first == b.first && a.second < b.second;
}
bool comp2(pair<long long, long long> a, pair<long long, long long> b) {
return a.second < b.second;
}
signed main() {
ios_... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
void solve() {
int n, k, m, pos;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
cin >> m;
for (int _ = 0; _ < m; _++) {
cin >> k >> pos;
vector<int> ind;
set<int> s;
for (int i = 0; i < k; i++) {
i... |
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
if (a.first > b.first)
return true;
else if (a.first == b.first) {
if (a.second < b.second) return true;
return false;
}
return false;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int i, j,... |
#include <bits/stdc++.h>
const double pi = 3.141592653589793238;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;
const int N = 3e5 + 5;
using namespace std;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
if (a.first != b.first) return (a.first > b.first);
return (a.second < b.second);
... |
#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)2e18 + 77;
void solve() {
int n;
cin >> n;
int a[n], i;
for (i = 0; i < n; i++) cin >> a[i];
map<int, int> N;
int M[n][n];
for (i = 0; i < n; i++) {
N[a[i]]++;
M[n - 1][i] = a[i];
}
for (i = n - 2; i >= 0; i... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int m;
cin >> m;
for (int e = 0; e < m; e++) {
int k, p;
cin >> k >> p;
vector<int> b;
for (int i = 0; i < k; i++) {
b.push_back(a[i]);
... |
#include <bits/stdc++.h>
using namespace std;
long long pw(long long a, long long b) {
if (b == 0) return 1;
if (b % 2 == 1)
return (a * pw((a * a) % 1000000007, b / 2)) % 1000000007;
else
return (1 * pw((a * a) % 1000000007, b / 2)) % 1000000007;
}
bool comp(pair<long long, long long> a, pair<long long, ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 1;
const int INF = 2e9 + 1;
const int MOD = (1e9 + 7);
void bye(string s = "") {
cout << s << '\n';
exit(0);
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vector<int> arr(n);
set<pair<... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
ll t = 1;
while (t--) {
int n;
cin >> n;
vector<int> v(n), temp(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
temp[i] = v[i];
}
sort(temp.begin(), temp.end(), greater<int>());
int m;
cin... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
while (t--) {
int n, x;
cin >> n;
vector<pair<int, int> > a(n);
for (int i = 0; i < n; i++) {
cin >> x;
a[i] = {-x, i};
}
sort(a.begin(), a.end());
in... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mo = 1e9 + 7;
long long sx, sy, ex, ey, dx[6] = {0, 1, 0, -1, 0, 0},
dy[6] = {1, 0, -1, 0, 0, 0}, m, n, k,
dz[6]{0, 0, 0, 0, -1, 1}, sg;
long long p, no, v, ans, w;
int par[55000... |
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using mii = map<int, int>;
const double Eps = 1e-8;
const int Inf = 1e9 + 9;
const int Mod = 1e9 + 7;
const int N = 1e5 + 9;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = LLONG_MAX - 100000;
void IO() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout.setf(ios::fixed);
}
long long pw(long long x, long long y, long long p = inf) {
long long res = 1;
x = x % p;
if (x ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
long long int n, m, k, i, j, a[101];
cin >> n;
vector<long long int> pr;
for (i = 0; i < n; i++) {
cin >> a[i];
pr.push_back(a[i]);
}
sort(pr.rbegin(), pr.rend());
cin >> m;
while ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n, 0), b(n, 0);
for (int i = 0; i < n; ++i) {
cin >> a[i];
b[i] = a[i];
}
sort(b.begin(), b.end());
int m;
cin >> m;
for (int i = 0; i < m; ++i) {
int k, pos;
cin >> k >> pos;
int x = b[n - k]... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
std::ios::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
long long t = 1;
while (t--) {
long long n;
cin >> n;
vector<long long> ar(n), br(n);
for (long long i = 0; i < n; i++) {
cin >> ar[i];
br[i] = ... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
long long a_s, b_s;
vector<long long> best(vector<long long> a, vector<long long> b) {
a_s = 0;
b_s = 0;
bool flaga = true;
bool flagb = true;
for (long long i = 0; i < a.size(); ++i)
if (a[i] < 0) flaga = false;
for (long long i ... |
#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[100];
int ind[100];
bool cmp(int i, int j) {
if (a[i].first == a[j].first) return a[i].second < a[j].second;
return a[i].first > a[j].first;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; ... |
#include <bits/stdc++.h>
using namespace std;
long long n, m, k, l, r, i, j, a[1000001], d[10000001], ans[1000001];
bool tt[1000001];
vector<pair<long long, long long> > v;
string s;
void build(long long h, long long l, long long r) {
if (l == r) {
d[h] = 0;
return;
}
long long w = (l + r) / 2;
build(h ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n;
cin >> n;
vector<long long int> a(n), v1(n);
for (long long int i = 0; i < n; i++) cin >> a[i];
v1 = a;
sort(a.begin(), a.end(), greater<long long int>());
long long int q;
ci... |
#include <bits/stdc++.h>
using namespace std;
int n, A[111];
map<int, set<int>> idxs;
set<int> app;
int main(void) {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &A[i]);
app.insert(A[i]);
idxs[A[i]].insert(i);
}
int q;
scanf("%d", &q);
while (q--) {
int k, pos;
scanf("%d%d... |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios ::sync_with_stdio(false);
cin.tie(0);
long long n;
cin >> n;
long long arr[n];
map<long long, long long> mp;
for (long long i = 0; i < n; i++) {
cin >> arr[i];
}
vector<long long> vrr(arr, arr + n);
sort(vrr.rbegin(), vrr.rend());... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1 << 62;
const long long MOD = 1e9 + 7;
const int iINF = 1 << 30;
const double PI = 3.14159265359;
int main() {
int n;
vector<pair<int, int> > a;
cin >> n;
a.assign(n, {0, 0});
for (int i = 0; i < n; i++) {
cin >> a[i].first;
... |
#include <bits/stdc++.h>
using namespace std;
bool mycomparator(pair<long long int, int> p1, pair<long long int, int> p2) {
if (p1.first == p2.first) {
if (p1.second > p2.second) {
return true;
} else {
return false;
}
}
if (p1.first < p2.first) {
return true;
} else {
return fal... |
#include <bits/stdc++.h>
using namespace std;
void jakos() {
ios_base::sync_with_stdio(false);
cin.tie(0);
}
const int mod = 1e9 + 7;
const int base = 179;
const int INF = 1e9;
const int N = 1e5;
signed main() {
jakos();
int n;
cin >> n;
vector<pair<int, int>> a;
for (int i = 0; i < n; i++) {
int b;
... |
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 105, inf = 0x3f3f3f3f;
int n;
int a[maxn], vis[maxn], b[maxn];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int m;
cin >> m;
for (int i = 1; i <= m; i++) {
int k, pos;
cin >> k >> pos;
int cnt = 0;
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m;
cin >> n;
long long x[n + 5];
for (long long i = 0; i < n; i++) {
cin >> x[i];
}
cin >> m;
long long ans = 1e+18;
deque<long long> y, z;
for (long long j = 0; j < m; j++) {
long long k, pos;
cin >> k >> pos;
y.c... |
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long int, int> p, pair<long long int, int> q) {
if (p.first > q.first)
return 1;
else if (p.first < q.first)
return 0;
else {
if (p.second < q.second)
return 1;
else
return 0;
}
}
int main() {
ios_base::sync_with_stdi... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
if (a.first < b.first) return true;
if (a.first > b.first) return false;
if (a.second < b.second) return false;
return true;
}
signed main() {
ios_base::sync_with_stdi... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int head[N];
int dis[N], ecnt;
int fa[N];
int cat[2005][2005];
long long gcd(long long a, long long b) {
return a % b == 0 ? b : gcd(b, a % b);
}
long long qpow(long long base, long long n) {
long long ans = 1;
while (n... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1 << 62;
const long long MOD = 1e9 + 7;
const int iINF = 1 << 30;
const double PI = 3.14159265359;
int LSOne(int n) { return n & (-n); }
class FenwickTree {
private:
vector<int> ft;
public:
FenwickTree(int n) { ft.assign(n + 1, 0); }
... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
long long a[N], id[N];
pair<long long, long long> G[N];
void Upd(int x, int y) {
while (x <= n) {
G[x].first++;
G[x].second += y;
x += (x & -x);
}
}
pair<long long, long long> Get(int x) {
pair<long long, long long> res;
res... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int N;
int position[maxn];
long long sum1[maxn << 2], sum2[maxn << 2];
void add(long long* bit, int pos, long long val) {
while (pos <= N) {
bit[pos] += val;
pos += pos & (-pos);
}
}
long long query(long long* bit, int pos) {
long lo... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int a[maxn];
class BIT {
public:
long long a[maxn];
void add(int x, long long c) {
for (int i = x; i < maxn; i += i & -i) a[i] += c;
}
long long sum(int x) {
long long res = 0;
for (int i = x; i > 0; i -= i & -i) res += a[i];
... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int a[N], p[N], inv[N], n;
int f[N + 1];
int read(int idx) {
int sum = 0;
idx++;
while (idx > 0) {
sum += f[idx];
idx -= (idx & -idx);
}
return sum;
}
void update(int idx, int val) {
idx++;
while (idx <= n) {
f[idx] += val;
i... |
#include <bits/stdc++.h>
using namespace std;
struct fenwick {
int N;
vector<int> bit;
fenwick(int n = 1e5) {
N = n + 5;
bit.assign(N, 0);
}
void resize(int n) {
N = n + 5;
bit.assign(N, 0);
}
void update(int x, int val) {
while (x < N) {
bit[x] += val;
x += x & -x;
}
... |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long sum1[maxn];
long long sum2[maxn];
long long n;
long long lowbit(long long x) { return x & -x; }
void add(long long *sum, long long x, long long v) {
while (x <= n) {
sum[x] += v;
x += lowbit(x);
}
}
long long query(long... |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 5;
long long c[maxn], d[maxn];
long long n;
long long lowbit(long long x) { return x & (-x); }
void update(long long i, long long k) {
while (i <= n) {
c[i] += k;
i += lowbit(i);
}
}
long long getsum(long long i) {
long long res = ... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int oo = 1e9 + 7;
int a[maxn], c[maxn], n;
int pos[maxn];
long long ans[maxn];
void update(int x) {
for (int i = x; i <= n && i; i += i & (-i)) c[i]++;
}
long long query(int x) {
long long ans = 0;
while (x) ans = ans + 1ll * c[x], x -=... |
#include <bits/stdc++.h>
using namespace std;
struct Node {
Node *l, *r;
int count;
long long sum;
int ask(int k, int ll, int rr) {
if (ll == rr) {
return count;
}
int mid = (ll + rr) >> 1;
if (k <= mid) {
return l ? l->ask(k, ll, mid) : 0;
} else {
return (l ? l->count : 0... |
#include <bits/stdc++.h>
using namespace std;
long long const inf = 1e9;
long long const mod = 1e9 + 7;
long double const eps = 1e-9;
long long bit[200005];
long long bit2[200005];
long long sumbit[200005];
long long n;
void update(long long k) {
while (k <= 200000) {
bit[k] += 1;
k += k & -k;
}
}
long long... |
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
int a[MAX], p[MAX], n;
long long c1[MAX], c2[MAX];
set<int> st;
void add(long long *c, int x, int k) {
for (; x <= n; x += x & -x) c[x] += k;
}
long long query(long long *c, int x) {
long long sum = 0;
for (; x; x -= x & -x) sum += c[x];
ret... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
long long pos[N], s1[N], s2[N];
int a[N];
int n;
void add(long long s[], int pos, long long v) {
while (pos <= n) {
s[pos] += v;
pos += pos & (-pos);
}
}
long long query(long long s[], int pos) {
long long res = 0;
while (pos) {
re... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long sum1[maxn << 2], sum2[maxn << 2];
int N, pos[maxn], a[maxn];
void update(long long* tree, int pos, int l, int r, int id, long long val) {
if (l > r || pos < l || pos > r) return;
if (pos == l && pos == r) {
tree[id] += val;
} e... |
#include <bits/stdc++.h>
using namespace std;
long long n, fwk[2][200001], ps[200001] = {}, pv[200001] = {}, to1 = 0, to2 = 0;
set<long long> s;
set<long long>::iterator it;
void upd(int x, int t, long long v) {
for (; x <= n; x += x & (-x)) {
fwk[t][x] += v;
}
}
long long qry(int x, int t) {
long long to = 0... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int a[N];
struct fenwick {
long long fen[N];
fenwick() { memset(fen, 0, sizeof fen); }
void add(int x, int d) {
for (int i = x + 1; i < N; i += i & -i) {
fen[i] += d;
}
}
long long sum(int x) {
long long ans = 0;
for (i... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
const long long INF = 1LL << 60;
const long long mod = 1e9 + 7;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
template <class T>
inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
templa... |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
const long long MAXN = 1e6 + 5;
long long n, m, t;
long long a[MAXN];
long long tree1[MAXN], tree2[MAXN];
long long pos[MAXN];
void add(long long *tree, long long x, long long xx) {
while (x <= n) tree[x] += xx, x += (x & (-x));
}
long long... |
#include <bits/stdc++.h>
using namespace std;
long long n, fwk[2][200001], ps[200001] = {}, pv[200001] = {}, to1 = 0, to2 = 0;
set<long long> s;
set<long long>::iterator it;
void upd(int x, int t, long long v) {
for (; x <= n; x += x & (-x)) {
fwk[t][x] += v;
}
}
long long qry(int x, int t) {
long long to = 0... |
#include <bits/stdc++.h>
using namespace std;
int p[200005];
long long ret[200005];
long long inv[200005], sum[200005];
void update(long long *pen, int ind, int val) {
while (ind < 200005) {
pen[ind] += val;
ind += ind & (-ind);
}
}
long long query(long long *pen, int ind) {
long long ret = 0;
while (in... |
#include <bits/stdc++.h>
using namespace std;
const int NN = (int)2e5 + 5;
int A[NN];
int pos[NN];
int n;
long long tree_cnt[NN];
long long tree_sum[NN];
long long read(long long* tree, int idx) {
idx++;
long long res = 0;
while (idx > 0) {
res += tree[idx];
idx -= (idx & (-idx));
}
return res;
}
void... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, a[200010], p[200010], c[200010];
long long inv[200010];
set<int> st;
set<int>::iterator it;
int Lowbit(int x) { return x & (-x); }
void Update(int x, int d) {
while (x <= n) {
c[x] += d;
x += Lowbit(x);
}
}
int Getsum(int x) {
... |
#include <bits/stdc++.h>
const int maxn = 200000 + 10;
class BIT {
private:
int n;
int bit[maxn];
public:
BIT(int size) {
n = size;
std::fill(bit, bit + size + 1, 0);
}
void add(int x, int v) {
while (x <= this->n) {
bit[x] += v;
x += ((x) & (-x));
}
}
int query(int x) {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.