text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
int n, k;
scanf("%d%d", &n, &k);
priority_queue<int, vector<int>, greater<int> > books, a, b;
for (int i = 0; i < n; i++) {
int ti, x, y;
scanf("%d%d%d", &ti, &x, &y);
if (x && y)
books.push(ti);
else if (x)
... |
#include <bits/stdc++.h>
using namespace std;
int t[200005], a[200005], b[200005];
long long sum1[200005], sum2[200005], sum3[200005], sum4[200005];
int val[200005];
int pos[200005];
vector<pair<int, int> > v1, v2, v3, v4, v5;
struct tree {
long long ft[200005];
void update(int i, int v) {
for (; i <= 200000; i... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long inf_ll = 1e18;
vector<pair<long long, int>> t[4];
array<long long, 3> eval(int x, int y) {
int l = max(-(int)(t[2].size() - 1 - x - y), 0),
r = min((int)t[1].size() - 1 - x, y);
while (l < r - 2) {
int mid = (l + r) / 2;
... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-ffloat-store")
#pragma GCC optimize("-fno-defer-pop")
long long int power(long long int a, long long int b, long long int m) {
if (b == 0) return 1;
if (b == 1) return a % m;
lon... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void out(T t) {
cout << t << "\n";
}
template <class T, class... Ts>
inline void out(T t, Ts... ts) {
cout << t << " ";
out(ts...);
}
template <class T>
inline bool CHMIN(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return fa... |
#include <bits/stdc++.h>
using namespace std;
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
void YES(bool t = 1) { cout << YESNO[t] << "\n"; }
void Yes(bool t = 1) { cout << YesNo[t] << "\n"; }
void yes(bool t = 1) { cout << yesno[t] << "\n"; }
cons... |
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int inf = 2e9 + 5;
double PI = 3.14159265358979323846;
void solve() {
long long int n, k;
cin >> n >> k;
vector<long long int> books[2][2];
for (int i = 0; i < n; i++) {
long long int t, a, b;
cin >> t >> a ... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = ... |
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int inf = 0x3f3f3f3f3f3f3f3fLL;
long long int i, j, k;
void solve(void);
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(10);
int t = 1;
while (t--) solve();
return 0;... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct node {
long long val = 0, num = 0;
};
vector<node> s(1 << 15);
long long dim = 1 << 14;
void add(long long pos, long long l, long long r, long long p) {
if (l > p || r... |
#include <bits/stdc++.h>
using namespace std;
template <typename Number>
Number gcd(Number u, Number v) {
while (v != 0) {
Number r = u % v;
u = v;
v = r;
}
return u;
}
long long int binSearch(vector<long long int> v, long long int l,
long long int r, long long int x) {
if (r... |
#include <bits/stdc++.h>
using namespace std;
struct Node {
int son[2], val, pri, siz;
int sum;
} t[2000086];
int cnt;
int root;
inline int rand() {
static int seed = 12345;
return seed = (int)seed * 482711LL % 2147483647;
}
void up(int x) {
t[x].siz = t[(t[x].son[0])].siz + t[(t[x].son[1])].siz + 1;
t[x].s... |
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::string;
void __Check(bool condition, const char* expression, int line) {
if (!condition) {
fprintf(stderr, "Check failed at line %d: %s\n", line, expression);
exit(-1);
}
}
template <class Collection, class Key>
bool Conta... |
#include <bits/stdc++.h>
using namespace std;
const int md = 1000000007;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt{}, T{};
tt = 1;
while (tt--) {
long long n{}, m{}, k{}, a{}, b{}, c{}, f{}, p = -1, sum = 0;
long long ans{};
cin >> n >> k;
std::vector<long long> alic... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, n, k, alike, blike, t, total = 0;
cin >> n >> k;
vector<int> a, b, coll;
for (i = 0; i < n; i++) {
cin >> t >> alike >> blike;
if (alike) {
if (blike)
coll.push_back(t);
else
a.push_back(t);
} else if (blik... |
#include <bits/stdc++.h>
using namespace std;
struct BookInfo {
int t;
int a;
int b;
int i;
};
struct CombinedBook {
int t;
BookInfo b1;
BookInfo b2;
bool isCombined;
};
int main() {
ios_base::sync_with_stdio(0);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(10);
cin.tie(0);
... |
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long PI = 3.14159265358979;
const long long INF = 1000000000000000000;
bool sortbysec(pair<long long, long long> a, pair<long long, long long> b) {
return (a.second < b.second);
}
long long powerMod(long long a, long long b, lo... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long n, k;
cin >> n >> k;
vector<long long> a;
vector<long long> b;
vector<long long> same;
for (long long i = 0; i < n; i++) {
long long t, x, y;
cin >> t >> x >> y;
i... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
void Output(const T& v, bool print_new_line = true) {
bool first = true;
for (auto element : v) {
if (!first)
cout << " ";
else
first = false;
cout << element;
}
if (print_new_line) cout << endl;
}
template <class T>
void I... |
#include <bits/stdc++.h>
using namespace std;
deque<long long> v11, v10, v01;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long n, k;
cin >> n >> k;
for (long long i = 0; i < n; i++) {
long long a, b, c;
cin >> a >> b >> c;
if (b == 1 && c == 1)
v11.emplace_back(a);
else if ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int stack_A[MAXN];
int stack_B[MAXN];
int stack_AB[MAXN];
int main() {
ios ::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
int a_cnt = 0;
int b_cnt = 0;
int ab_cnt = 0;
int x, y, z;
for (int i = 0; i < n; ++i) {
... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int maxn = 1e6 + 10;
const double eps = 1e-9;
const long long inf = 1e18;
int T;
int n, m, k;
vector<long long> vec[5];
long long a, b, t;
int main() {
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i++) {
scanf("%lld%lld%lld",... |
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios {
fast_ios() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
};
} fast_ios_;
template <typename T>
istream &operator>>(istr... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, t, a, b;
long long ans = 0;
priority_queue<int, vector<int>, greater<int>> book[3];
scanf("%d%d", &n, &k);
while (n--) {
scanf("%d%d%d", &t, &a, &b);
if (a && b)
book[0].push(t);
else if (a)
book[1].push(t);
else ... |
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 200001;
struct E {
int i, t;
bool operator<(const E &e) const { return t < e.t; }
bool operator>(const E &e) const { return t > e.t; }
} e[4][kMaxN];
bool s[kMaxN];
int c[4];
int n, m, k, x, a, b, ans, sum, tot, p;
priority_queue<E> bh;
priority_queu... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n, k, t, a, b;
cin >> n >> k;
vector<long long int> time, alice, bob, both;
for (long long int i = 0; i < n; i++) {
cin >> t >> a >> b;
if (a && b) {
both... |
#include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
scanf("%lld%lld", &n, &k);
vector<long long> v, ali, bob;
for (int i = 0; i < n; i++) {
long long t, x, y;
scanf("%lld%lld%lld", &t, &x, &y);
if (x == 1 && y == 1)
v.push_back(t);
else if (x == 1 && y == 0)
ali.... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
vector<long long> a, b, ab;
int count_a = 0, count_b = 0;
for (int i = 0; i < n; i++) {
int t;
bool b1, b2;
cin >> t >> b1 >> b2;
if (b1 && b2) {
ab.pu... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n, k;
cin >> n >> k;
long long t[n], a[n], b[n];
vector<long long> ali, bob, both;
for (long long i = 0; i < n; i++) {
cin >> t[i] >> a[i] >> b[i];
if (a[i] == 1 &&... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
int n, m, k, sa, sb, ans = 2e9 + 10000, calc, x, ty, sz1, res[N], tim;
struct item {
int t, a, b;
} a[N];
vector<pair<int, int> > b[4];
priority_queue<pair<int, int> > s, t;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
i... |
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
int isPrime(int n) {
if (n < 2) return 0;
if (n < 4) return 1;
if (n % 2 == 0 or n % 3 == 0) return 0;
for (int i = 5; i * i <= n; i += 6)
if (n % i == 0 or n % (i + 2) == 0) return 0;
r... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long INFF = 1e18;
const long long MAXN = 510;
const long long MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
... |
#include <bits/stdc++.h>
using namespace std;
bool isrange(int second, int first, int n, int m) {
if (0 <= second && second < n && 0 <= first && first < m) return true;
return false;
}
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1},
ddy[8] = {1, 0, -1, 0, 1, 1, -1, -1}, ddx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
p... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
int size(const T& x) {
return x.size();
}
using namespace std;
void solve(int test_case) {
int n, k;
cin >> n >> k;
vector<int> tBoth, tAlice, tBob;
for (int i = 0; i < n; i++) {
int t, a, b;
cin >> t >> a >> b;
if (a == 1 && b == 1)... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n, k;
cin >> n >> k;
long long ans = 0;
int i, j, cnta = 0, cntb = 0, time = 0;... |
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long N = 2e5 + 1;
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long t;
t = 1;
while (t--) {
long long n, k;
std::cin >> n >> k;
long long sum = 0, pp = 0, i, ta[n], a[n],... |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long n, k;
cin >> n >> k;
vector<long long> arr1, arr2, arr3;
for (long long i = 0; i < n; i++) {
long long t, a, b;
cin >> t >> a >> b;
if (a == 1 && b == 1) arr1.push_back(t);
if (a == 1... |
#include <bits/stdc++.h>
using namespace std;
const int NR = 4e5 + 10;
void Min(int& x, int y) { x = min(x, y); }
void Max(int& x, int y) { x = max(x, y); }
int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && c... |
#include <bits/stdc++.h>
using namespace std;
void Ios() {
ios::sync_with_stdio(false);
cin.tie(0);
return;
}
constexpr int kN = int(2E5 + 10), kInf = int(2E9 + 10);
mt19937_64 rng;
struct Treap {
struct Node {
Node *l, *r;
int val, sz, sum;
long long int wei;
Node() {}
Node(int x) {
l... |
#include <bits/stdc++.h>
using namespace std;
long long dp[2000005];
long long a[2000005];
int main() {
long long q;
q = 1;
for (int r = 0; r < q; r++) {
long long n, k;
cin >> n >> k;
vector<int> ans;
vector<int> a;
vector<int> b;
long long x, y, z;
for (int i = 0; i < n; i++) {
... |
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const float pi = 3.141592653;
long long power(long long a, long long b) {
if (b == 0) return 1;
long long p = power(a, b / 2);
if (b & 1)
return p * p * a;
else
return p * p;
}
void solve() {
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
priority_queue<int, vector<int>, greater<int>> ab;
priority_queue<int, vector<int>, greater<int>> av;
priority_queue<int, vector<int>, greater<int>> bv;
int n, k;
cin >> n >> k;
int cntA, cntB;
... |
#include <bits/stdc++.h>
using namespace std;
int reading_books(int n, int k, vector<int>& t, vector<int>& a,
vector<int>& b) {
int cnt_a, cnt_b, total;
vector<int> av, bv, cv;
total = 0;
cnt_a = cnt_b = k;
auto choose_alice = [&]() {
total += av.back();
cnt_a = max(0, cnt_a - 1);
... |
#include <bits/stdc++.h>
using namespace std;
vector<int> a, b, c, tmp;
int main() {
ios::sync_with_stdio(false);
long long n, k;
cin >> n >> k;
for (long long i = 1; i <= n; i++) {
long long a1, b1, t;
cin >> t >> a1 >> b1;
if (a1 == 1 && b1 == 1) {
c.push_back(t);
} else {
if (a1) ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int n, count;
cin >> n >> count;
vector<long long int> both, alice, bob;
long long int time, b, c;
for (int i = 0; i < n; i++) {
cin >> time >> b >> c;
if (b == 1 && c ... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 1;
int main() {
int n, k;
cin >> n >> k;
vector<int> times[4];
vector<int> sums[4];
for (int i = 0; i < n; ++i) {
int t, a, b;
cin >> t >> a >> b;
times[a * 2 + b].push_back(t);
}
for (int i = 0; i < 4; ++i) {
sort(times[i... |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(98);
struct node {
int x, y, c;
long long s;
node *l, *r;
node(int x) : x(x), y(rng()), l(nullptr), r(nullptr) {
c = 1;
s = x;
}
void recalc();
};
int cnt(node *n) { return n ? n->c : 0; }
long long sum(node *n) { return n ? n->s : 0; }
void ... |
#include <bits/stdc++.h>
using namespace std;
long long int a, b, c, d, e, f = 5 * 1e9, m11[200000], m01[200000], m10[200000],
k, k1, k2;
int main() {
cin >> a >> b;
for (int i = 0; i < a; i++) {
cin >> c >> d >> e;
if (e == 1 && d == 1) m11[k] = c, k++;
if (d == 1 && e == 0... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const double pi = acos(-1);
const double eps = 1e-9;
const int mod = 1e9 + 7;
const int mf[] = {0, 0, 1, -1}, mc[] = {1, -1, 0, 0};
const int N = 1005;
mt19937 rng(
(unsigned int)chrono::steady_clock::now().time_since_epoch().count());
template ... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
struct indices {
int i11, i10, i01, i00;
};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
vector<pair<long long int, int> > v11, v10, v01, v00;
for (int i = 0; i < n; i++) {
int t, a, b;
ci... |
#include <bits/stdc++.h>
using namespace std;
void adskiy_razgon() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0},
dyo[... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, -1, 0, 1};
vector<pair<long long, long long> > v[4];
long long n, m, k;
vector<long long> uttar;
bool check = false;
long long call(long long x) {
check = false;
if (x > m) {
check =... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n, k;
cin >> n >> k;
vector<long long> ones, twos, threes;
for (long long i = 0; i < n; i++) {
long long t, a, b;
cin >> t >> a >> b;
if (a == 1 && b == 1) {
th... |
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 998244353;
const long double PI = 3.14159265359;
const long long int INF = 1e9;
char salpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v', '... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int k, n;
cin >> n >> k;
int aa[n], ba[n], ra[n];
int r = 0, a = 0, b = 0;
for (int i = 0, v, m, u; i < n; ++i) {
cin >> v >> m >> u;
if (m && u)
ra[r++] = v;
else if (u)
ba[b++] = v;
else if (m)
aa[a++] = v;
}
so... |
#include <bits/stdc++.h>
using std::max;
using std::min;
const int N = 2e5 + 5, INF = 0x7fffffff;
struct book {
int id, val, a, b;
book() {}
book(int val, int a, int b) : val(val), a(a), b(b) {}
bool operator<(const book &rhs) const { return val < rhs.val; }
bool operator>(const book &rhs) const { return val ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10, mod = 1e9 + 7;
int bitc[N], bit[N];
int n;
void add(int i, int va) {
for (; i < N; i += (i & -i)) {
bit[i] += va;
bitc[i] += (va < 0 ? -1 : 1);
}
}
long long getprefones(int va) {
int i = 0;
int cur = 0;
long long ret = 0;
for (in... |
#include <bits/stdc++.h>
using namespace std;
bool rev(long long x, long long y) { return x > y; }
void input_arr(long long a[], long long n) {
for (long long i = 0; i < n; i += 1) cin >> a[i];
}
bool sortbysec(const pair<long long, long long> &a,
const pair<long long, long long> &b) {
return a.secon... |
#include <bits/stdc++.h>
using namespace std;
int N = INT_MAX;
long long INF1 = 1e9 + 5;
long long INF2 = 1e18L + 5;
map<long long, long long> my;
int h[10005];
int main() {
int n, k;
cin >> n >> k;
int chk1 = 0, chk2 = 0;
int a, b, c;
vector<int> v1, v2, v3;
for (int i = 0; i < n; i++) {
cin >> a >> b ... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a, b, c;
for (int i = 0; i < n; i++) {
int x, y, z;
cin >> x >> y >> z;
if (y == 0 && z == 0)
continue;
else if (y == 1 && z == 0)
a.push_back(x);
else if (y == 0 && z == 1)
b.... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
class segTree {
public:
vector<long long> t;
int n;
segTree(int n) {
t.resize(n * 2 + 5, 0);
this->n = n;
}
void build() {
for (int i = n - 1; i > 0; --i) t[i] = t[i << 1] + t[i << 1 | 1];
}
void update(int p, long long... |
#include <bits/stdc++.h>
using namespace std;
const int M = 998244353;
vector<int> both, al, bob;
int k;
int good(int cnt, int mi, int ma) {
if (cnt > mi && (both[cnt - 1] > al[k - cnt] + bob[k - cnt])) return -1;
if (cnt < ma && (both[cnt] < al[k - cnt - 1] + bob[k - cnt - 1])) return 1;
return 0;
}
int main() {... |
#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e5 + 7;
const int N = 2e6 + 5;
int arr[N];
int idx[4] = {0, 0, 0, 0};
vector<int> vec[4];
int take(int x) {
if (vec[x].size() <= idx[x]) return Mod;
return vec[x][idx[x]++];
}
int get(int x) {
if (vec[x].size() <= idx[x]) return Mod;
return ar... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T1, typename T2>
inline void chkmin(T1 &x, const T2 &y) {
if (x > y) x = y;
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, const T2 &y) {
if (x < y) x = y;
... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0;
char ch;
while (!isdigit(ch = getchar()))
;
x = ch - 48;
while (isdigit(ch = getchar())) x = x * 10 + ch - 48;
return x;
}
const int MAXN = 2e5 + 5;
int n, m, k;
vector<pair<int, int> > t[4], tmp;
vector<int> ans;
inline int ca... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
multiset<int> v, v0, v1;
for (int i = 0; i < n; i++) {
int t, a, b;
cin >> t >> a >> b;
if (a == 0 && b == 0) continue;
if (a == 0 && b == 1) {
v1.insert(t);
}
if (a == 1 && b == 0) v0.insert(t);
... |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
long long ii = 1;
void solve() {
long long n;
long long kk;
cin >> n >> kk;
vector<long long> alice;
vector<long long> bob;
vector<long long> all;
long long al = 0;
long long bo = 0;
for (long long i = 0; i < n; i++) {
long lon... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<long long> a;
vector<long long> b;
vector<long long> m;
for (long long i = 0; i < n; i = i + 1) {
long long t, aa, bb;
cin >> t >> aa >> bb;
if (aa == 1 && bb == 0) {
a.push_back(t);
}
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<tuple<long long, long long, long long>> v;
long long x = 0, y = 0, z = 0;
for (long long i = 0; i < n; i++) {
long long a, b, c;
cin >> a >> b >> c;
v.push_back(make_tuple(a, b, c));
if (b == 1 && ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
if (a[0] + a[1] <= a.back()) {
cout << "1 2 " << n << '\n';
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t, n;
long long arr[1000000];
cin >> t;
for (int a = 1; a <= t; a++) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
if (arr[0] + arr[1] <= arr[n - 1]) {
cout << 1 << " " << 2 << " " << n << "\n";
} e... |
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long int;
ll binpow(ll a, ll b) {
ll res = 1;
while (b > 0) {
if (b & 1) {
res = res * a;
}
a = a * a;
b >>= 1;
}
return res;
}
void solve() {
ll n;
cin >> n;
ll ar[n + 1];
for (ll i = 0; ... |
#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
int t, n, a, b, c, d;
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) {
if (i == 0)
scanf("%d", &a);
else if (i == 1) {
scanf("%d", &b);
} else if (i == (n - ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> vc(n);
for (int i = 0; i < n; i++) {
cin >> vc[i];
}
int i;
int count = 0;
for (i = 0; i < n - 2; i++) {
if (vc[i] + vc[i + 1] <= vc[n - 1]) {
... |
#include <bits/stdc++.h>
using namespace std;
void IO() {}
int ar[50005];
char ch[50005];
int m, n, k, ii;
void solve() {
scanf("%d", &n);
vector<pair<int, int>> v;
for (int i = 1; i <= n; i++) {
scanf("%d", &ar[i]);
v.push_back({ar[i], i});
}
sort(v.begin(), v.end());
if (v[0].first + v[1].first <=... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> v(n);
for (auto &i : v) cin >> i;
if (v[0] + v[1] > v[n - 1])
cout << "-1\n";
else
cout << 1 << " " << 2 << " " << n <... |
#include <bits/stdc++.h>
using namespace std;
inline int Int() {
int x;
cin >> x;
return x;
}
inline long long Long() {
long long x;
cin >> x;
return x;
}
inline float Float() {
float x;
cin >> x;
return x;
}
inline double Double() {
double x;
cin >> x;
return x;
}
inline void Yes() { cout << "Y... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, i;
cin >> n;
vector<long long> v(n);
for (i = 0; i < n; i++) cin >> v[i];
if (v[0] + v[1] <= v[n - 1])
cout << '1' << " " << '2' << " " << n << "\n";
else
cout << "-1"
<< "\n";
return;
}
int main() {
ios_base::syn... |
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long x, long long y) {
if (y == 0) return x;
return GCD(y, x % y);
}
long long LCM(long long x, long long y) { return (x * y) / (GCD(x, y)); }
long long LOGK(long long x, long long k) {
if (x >= k) return 1 + LOGK(x / k, k);
return 0;
}
long long ... |
#include <bits/stdc++.h>
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
int a[50005];
for (int x = 0; x < n; x++) {
scanf("%d", &a[x]);
}
if (a[0] + a[1] > a[n - 1]) {
printf("-1\n");
} else {
printf("1 2 %d\n", n);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 5e4 + 10;
int a[N];
void solve() {
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i];
cout << (a[0] + a[1] > a[n - 1] ? "-1" : "1 2 " + to_string(n)) << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int size;
cin >> size;
std::vector<int> v(size);
for (auto& x : v) cin >> x;
if (v[0] + v[1] > v[size - 1])
cout << -1 << endl;
else
cout << 1 << " " << 2 << " " << size << endl;
}
ret... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int N = 1e5 + 5;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<long long int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
int a[n + 1];
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
if (a[0] + a[1] > a[n - 1]) {
printf("-1\n");
continue;
} else {
printf("%d... |
#include <bits/stdc++.h>
using namespace std;
const long long max_n = 1000000000;
int main() {
long long t;
cin >> t;
while (t--) {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
int a = arr[0];
int b = arr[1];
int c = arr[... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int v[n];
for (int i = 0; i < n; i++) {
cin >> v[i];
}
if (v[0] + v[1] <= v[n - 1])
cout << 1 << " " << 2 << " " << n << endl;
else
cout << -1 << endl;
}
ret... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 501011;
int a[MAXN];
int main() {
int T;
scanf("%d", &T);
while (T--) {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
if (a[1] + a[2] > a[n])
printf("-1\n");
else
printf("1 2 %d\n", n);
}
... |
#include <bits/stdc++.h>
int main() {
int t;
scanf("%d", &t);
while (t--) {
long long int n, i, j, k, f = 0;
scanf("%lld", &n);
long long int a[n];
for (i = 0; i < n; i++) scanf("%lld", &a[i]);
if (a[0] + a[1] <= a[n - 1])
printf("1 2 %lld\n", n);
else
printf("-1\n");
}
ret... |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long maxn = 3e6;
const long long mod = 1e9 + 7;
const long double PI = acos((long double)-1);
long long pw(long long a, long long b, long long md = mod) {
long long res = 1;
while (b) {
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int t, i, j, a, n;
cin >> t;
while (t--) {
cin >> n;
long long int a[n + 5], f = 0;
for (i = 0; i < n; i++) cin >> a[i];
for (i = 0; i < n - 2; i++) {
if (a[i... |
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int n;
cin >> n;
while (n--) {
int t;
cin >> t;
map<int, int> mp;
int a[t], b[3];
for (int i = 0; i < t; i++) {
cin >> a[i];
mp[a[i]] = i + 1;
}
sort(b, b + 3);
if (a[0] + a[1] > a[t - 1]) {
cout << -1... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, flag1 = 0, flag2 = 0;
cin >> n;
long long a[n];
for (int i = 0; i < n; i++) cin >> a[i];
if ((a[0] + a[1]) <= a[n - 1]) {
cout << "1 "
<< "2 " << n << endl;
} else {
cout... |
#include <bits/stdc++.h>
using namespace std;
struct HASH {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[50001];
for (int i = 0; i < n; i++) cin >> a[i];
if (a[0] + a[1] > a[n - 1]) {
cout << -1 << endl;
} else {
cout << 1 << " " << 2 << " " << n << endl;
}
}
re... |
#include <bits/stdc++.h>
#pragma GCC optimizer("O3")
#pragma GCC target("sse4")
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
vector<long long int> a(n);
for (long long int i = 0; i < n; i++)... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long arr[n];
for (long long i = 0; i < n; i++) {
cin >> arr[i];
}
vector<long long> ans;
long long temp = arr[n - 1] - arr[0];
long long i = 0;
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, val;
vector<int> v;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> n;
for (int j = 0; j < n; j++) {
cin >> val;
v.push_back(val);
}
if (v[0] + v[1] > v[n - 1]) {
cout << -1 << endl;
} else {
cout << ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
vector<vector<int>> v(t);
int n;
int temp;
for (int i = 0; i < t; i++) {
cin >> n;
v[i].reserve(n);
for (int j = 0; j < n; j++) {
cin >> temp;
v[i].push_back(temp);
}
}
for (int i = 0; i < t; i++) {
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
long long int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
if (a[0] + a[1] > a[n - 1])
cout << -1 << endl;
else
cout << 1 << " " << 2 << " " << n << endl;
}
... |
#include <bits/stdc++.h>
using namespace std;
void solve(bool& flag) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (n < 3) {
return;
} else {
if (a[0] + a[1] <= a[n - 1]) {
cout << 1 << " " << 2 << " " << n << endl;
flag = true;
}
}
}
in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.