More problems, update template

This commit is contained in:
2026-09-24 13:29:53 +01:00
parent c5efae17e4
commit 218fd77c8c
23 changed files with 766 additions and 0 deletions
+98
View File
@@ -0,0 +1,98 @@
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
// ----- TYPES -----
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int n; cin >> n
#define takeII(n,m) int n, m; cin >> n >> m
#define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k
#define takeL(n) ll n; cin >> n
#define takeS(s) string s; cin >> s
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- PAIRS -----
#define fi first
#define se second
// ----- OUTPUT -----
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,SZ(a)-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
#define SZ(c) ((int)(c).size())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(ALL(c), greater<>())
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
#define pb push_back
int main() {
FASTIO;
takeI(t);
while (t--) {
takeII(n,m);
takeV(a, n);
long long maxPillScore = LLONG_MIN;
priority_queue<int> smallestBeforeBM;
if (m == 1) {
cout << *max_element(a.begin(), a.end()) << NL;
continue;
}
long long totalBeforeBM = 0;
F(i,0,m-1) {
smallestBeforeBM.push(a[i]);
totalBeforeBM += a[i];
}
F(i, m-1, n) {
int ai = a[i];
long long cand = (long long)m * ai - totalBeforeBM;
maxPillScore = max(maxPillScore, cand);
int top = smallestBeforeBM.top();
if (ai < top) {
smallestBeforeBM.pop();
smallestBeforeBM.push(ai);
totalBeforeBM -= top;
totalBeforeBM += ai;
}
}
cout << maxPillScore << NL;
}
}
@@ -0,0 +1,89 @@
#include <bits/stdc++.h>
using namespace std;
// ----- TYPES -----
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int n; cin >> n
#define takeII(n,m) int n, m; cin >> n >> m
#define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k
#define takeL(n) ll n; cin >> n
#define takeS(s) string s; cin >> s
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- PAIRS -----
#define fi first
#define se second
// ----- OUTPUT -----
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,SZ(a)-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
#define SZ(c) ((int)(c).size())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(ALL(c), greater<>())
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
#define pb push_back
int factorial(int x) {
if (x == 0) return 1;
return x * factorial(x - 1);
}
int main() {
FASTIO;
takeI(t);
while(t--) {
takeI(n);
takeV(a, n);
int MOD = 998244353;
SORT(a);
reverse(ALL(a));
ll totalTrees = 1;
F(i,1,n) totalTrees = totalTrees * i % MOD;
ll res = 0;
ll prefix = a[0];
for (ll i = 1; i < n; i++) {
ll s = ((prefix - i * a[i]) % MOD + MOD) % MOD;
ll frequency = totalTrees / i;
res = (res + frequency * s) % MOD;
prefix += a[i];
}
cout << res << NL;
}
}
+78
View File
@@ -0,0 +1,78 @@
#include <bits/stdc++.h>
using namespace std;
// ----- TYPES -----
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int n; cin >> n
#define takeII(n,m) int n, m; cin >> n >> m
#define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k
#define takeL(n) ll n; cin >> n
#define takeS(s) string s; cin >> s
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- PAIRS -----
#define fi first
#define se second
// ----- OUTPUT -----
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,SZ(a)-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
#define SZ(c) ((int)(c).size())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(ALL(c), greater<>())
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
#define pb push_back
int main() {
FASTIO;
takeI(t);
while (t--) {
takeII(n, k);
if (k < n) {
cout << -1 << NL;
continue;
}
int val = n+1;
F(i,0,n) {
F(j,0,n) {
if (i == j) cout << i + 1 << ' ';
else cout << val++ << ' ';
}
cout << NL;
}
}
}
+73
View File
@@ -0,0 +1,73 @@
#include <bits/stdc++.h>
using namespace std;
// ----- TYPES -----
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int n; cin >> n
#define takeII(n,m) int n, m; cin >> n >> m
#define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k
#define takeL(n) ll n; cin >> n
#define takeS(s) string s; cin >> s
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- PAIRS -----
#define fi first
#define se second
// ----- OUTPUT -----
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,SZ(a)-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
#define SZ(c) ((int)(c).size())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(ALL(c), greater<>())
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
#define pb push_back
int main() {
FASTIO;
takeI(t);
while(t--) {
takeI(n);
takeV(a,n);
int ones = 0, zeros = 0;
for (auto x : a) if (x == 1) ones++; else zeros++;
// ones = 2
// zeros = 1
if (ones >= zeros) cout << "Bessie" << NL;
else cout << "Elsie" << NL;
}
}
+63
View File
@@ -0,0 +1,63 @@
#include <bits/stdc++.h>
using namespace std;
// ----- TYPES -----
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int n; cin >> n
#define takeII(n,m) int n, m; cin >> n >> m
#define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k
#define takeL(n) ll n; cin >> n
#define takeS(s) string s; cin >> s
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- PAIRS -----
#define fi first
#define se second
// ----- OUTPUT -----
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,SZ(a)-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
#define SZ(c) ((int)(c).size())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(ALL(c), greater<>())
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
#define pb push_back
int main() {
STDIO("nezzar-and-lucky-number");
takeI(n);
DBG(n);
}
+63
View File
@@ -0,0 +1,63 @@
#include <bits/stdc++.h>
using namespace std;
// ----- TYPES -----
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int n; cin >> n
#define takeII(n,m) int n, m; cin >> n >> m
#define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k
#define takeL(n) ll n; cin >> n
#define takeS(s) string s; cin >> s
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- PAIRS -----
#define fi first
#define se second
// ----- OUTPUT -----
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,SZ(a)-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
#define SZ(c) ((int)(c).size())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(ALL(c), greater<>())
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
#define pb push_back
int main() {
STDIO("odd-divisor");
takeI(n);
DBG(n);
}
View File
+1
View File
@@ -0,0 +1 @@
https://codeforces.com/contest/2264/problem/A
+93
View File
@@ -0,0 +1,93 @@
#include <bits/stdc++.h>
using namespace std;
// ----- TYPES -----
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int n; cin >> n
#define takeII(n,m) int n, m; cin >> n >> m
#define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k
#define takeL(n) ll n; cin >> n
#define takeS(s) string s; cin >> s
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- PAIRS -----
#define fi first
#define se second
// ----- OUTPUT -----
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,SZ(a)-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
#define SZ(c) ((int)(c).size())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(ALL(c), greater<>())
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
#define pb push_back
int main() {
FASTIO;
takeI(t);
while (t--) {
takeI(n);
vector<int> p(n);
F(i, 0, n) {
int x;
cin >> x;
// Stop one based indexing
p[i] = x-1;
}
// Find elements where p[i] != i (what we want to achieve with the operation)
vector<int> subSequence;
F(i, 0, n) {
if (p[i] != i) subSequence.pb(p[i]);
}
// Want to find if subsequence is decreasing
bool subSequenceDecreasing = true;
if (subSequence.size() == 0) goto end;
F(i, 0, subSequence.size()-1) {
if (subSequence[i] < subSequence[i+1]) {
subSequenceDecreasing = false;
break;
}
}
end:
YESNO(subSequenceDecreasing);
}
}
+63
View File
@@ -0,0 +1,63 @@
#include <bits/stdc++.h>
using namespace std;
// ----- TYPES -----
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int n; cin >> n
#define takeII(n,m) int n, m; cin >> n >> m
#define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k
#define takeL(n) ll n; cin >> n
#define takeS(s) string s; cin >> s
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- PAIRS -----
#define fi first
#define se second
// ----- OUTPUT -----
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,SZ(a)-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
#define SZ(c) ((int)(c).size())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(ALL(c), greater<>())
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
#define pb push_back
int main() {
STDIO("same-parity-subcommands");
takeI(n);
DBG(n);
}
+80
View File
@@ -0,0 +1,80 @@
#include <bits/stdc++.h>
using namespace std;
// ----- TYPES -----
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
#define SP ' '
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int n; cin >> n
#define takeII(n,m) int n, m; cin >> n >> m
#define takeIII(n,m,k) int n, m, k; cin >> n >> m >> k
#define takeL(n) ll n; cin >> n
#define takeS(s) string s; cin >> s
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- PAIRS -----
#define fi first
#define se second
// ----- OUTPUT -----
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,SZ(a)-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
#define SZ(c) ((int)(c).size())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(ALL(c), greater<>())
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
#define pb push_back
int main() {
FASTIO;
takeI(t);
while(t--) {
takeI(n);
takeV(a,n);
// Bessie & elsie
int b, e;
/**
B: 1, 2, 3
E: 3, 3
B: 3
Each have 3
*/
cout << b << SP << e << NL;
}
}