A.[两数之和](https://atcoder.jp/contests/abc365/tasks/abc365_a)
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
void Miraitowa(){
int n;
cin >> n;
if(n<=2)
cout << "NO" << endl;
else{
cout << "YES" << endl;
cout<<1<<" "<<n-1<<endl;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
Miraitowa();
return 0;
};
B.[ 小红装匣子](https://atcoder.jp/contests/abc365/tasks/abc365_b)
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const int mod = 1e9 + 7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
void Miraitowa()
{
ll a,b,n,m;
cin>>a>>b>>n;
b=(b/2);
m=min(b,n/3);
if(a*2>=(n-m*3)*2) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--)
Miraitowa();
return 0;
};
C.[小红的数字对对碰](https://atcoder.jp/contests/abc364/tasks/abc364_c)
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const int mod = 1e9 + 7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
ll n;
const int N = 3e5 + 10;
ll a[N];
void Miraitowa()
{
map<ll,ll>mp;
int n;
cin>>n;
ll cnt1=0,cnt2=0;
for(int i=1;i<=n;i++){
cin>>a[i];
if(a[i]>0) mp[a[i]]++;
else cnt1++;
}
for(auto it:mp) cnt2+=it.second%2;
if(cnt1<=cnt2) cout<<cnt2-cnt1<<endl;
else cout<<(cnt1-cnt2)%2<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
Miraitowa();
return 0;
};
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const int mod = 1e9 + 7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
const int N = 1e6 + 10;
ll n, a[N];
ll sum[N][40];
void Miraitowa()
{
ll n;
cin >> n;
priority_queue<string> q;
while (n--)
{
string s;
cin >> s;
q.push(s);
}
while(q.size()){
string ss = q.top();
q.pop();
cout << ss[0];
if(ss.size()!=1) q.push(ss.substr(1));
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
Miraitowa();
return 0;
};
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
ll x = 0, y = 1;
char c = getchar();
while (!isdigit(c))
{
if (c == '-')
y = -1;
c = getchar();
}
while (isdigit(c))
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x *= y;
}
inline void write(ll x)
{
if (x < 0)
x = -x, putchar('-');
ll sta[35], top = 0;
do
sta[top++] = x % 10, x /= 10;
while (x);
while (top)
putchar(sta[--top] + '0');
}
const int N = 3e5 + 10;
ll p[N], w[N], mmax[N];
int n, m;
int find(int x){
if(p[x]!=x) p[x] = find(p[x]);
return p[x];
}
void Miraitowa(){
cin >> n >> m;
for (int i = 1; i <= n;i++)
p[i] = i;
for (int i = 1; i <= n;i++)
cin >> w[i];
for (int i = 1; i <= n; i++)
mmax[i] = w[i];
while(m--){
ll a, b;
cin >> a >> b;
if(find(a)==find(b)) continue;
mmax[find(b)] = max(mmax[find(b)], mmax[find(a)]);
p[find(a)] = find(b);
}
vector<ll> vec;
for (int i = 1; i <= n;i++)
if(p[i]==i) vec.push_back(mmax[i]);
ll res = 0;
sort(vec.begin(), vec.end());
for (int i = 1; i < vec.size();i++)
res += vec[i];
cout << res << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
Miraitowa();
return 0;
};