mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-08-22 03:01:43 +00:00
update
This commit is contained in:
parent
129d41e2ac
commit
fb5c203e58
42
src/7/21/T636327d.cpp
Normal file
42
src/7/21/T636327d.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <climits>
|
||||||
|
using namespace std;
|
||||||
|
using ll = long long;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
cout.tie(nullptr);
|
||||||
|
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
ll A = 0, C = 0, B = 0, X = 0, Y = 0, Z = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
ll a, b, c;
|
||||||
|
cin >> a >> b >> c;
|
||||||
|
|
||||||
|
A += a;
|
||||||
|
C += c;
|
||||||
|
B += b;
|
||||||
|
X += min(a, b);
|
||||||
|
Y += min(c, b);
|
||||||
|
if (b > c) {
|
||||||
|
Z += min(a, b - c);
|
||||||
|
}
|
||||||
|
|
||||||
|
ll c1 = A;
|
||||||
|
ll c2 = C;
|
||||||
|
ll c3 = B / 2;
|
||||||
|
ll c4 = X;
|
||||||
|
ll c5 = Y;
|
||||||
|
ll c6 = (Y + Z) / 2;
|
||||||
|
|
||||||
|
ll ans = min({c1, c2, c3, c4, c5, c6});
|
||||||
|
cout << ans << '\n';
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
41
src/7/21/T636329.cpp
Normal file
41
src/7/21/T636329.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
#include <istream>
|
||||||
|
#include <limits>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
ll n,m;
|
||||||
|
std::vector<ll> a,b;
|
||||||
|
ll ans=std::numeric_limits<ll>::max();
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
std::iostream::sync_with_stdio(false);
|
||||||
|
std::cin.tie(nullptr);
|
||||||
|
std::cout.tie(nullptr);
|
||||||
|
|
||||||
|
std::cin>>n>>m;
|
||||||
|
a.resize(n+1);
|
||||||
|
b.resize(n+1);
|
||||||
|
|
||||||
|
for(ll i=1;i<=n;i++){
|
||||||
|
std::cin>>a[i];
|
||||||
|
}
|
||||||
|
for(ll i=1;i<=n;i++){
|
||||||
|
std::cin>>b[i];
|
||||||
|
}
|
||||||
|
std::sort(a.begin()+1,a.end());
|
||||||
|
std::sort(b.begin()+1,b.end());
|
||||||
|
while (std::next_permutation(a.begin()+1,a.end())) {
|
||||||
|
while(std::next_permutation(b.begin()+1,b.end())){
|
||||||
|
ll nans = std::numeric_limits<ll>::min();
|
||||||
|
for(ll i=1;i<=n;i++){
|
||||||
|
nans=std::max(nans,(a[i]+b[i])%m);
|
||||||
|
}
|
||||||
|
ans=std::min(nans,ans);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout<<ans<<'\n';
|
||||||
|
}
|
75
src/7/21/T636331.cpp
Normal file
75
src/7/21/T636331.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
#include <limits>
|
||||||
|
#include <set>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
ll T,n;
|
||||||
|
std::vector<std::vector<ll>> ta,tb;
|
||||||
|
ll ans=std::numeric_limits<ll>::max();
|
||||||
|
|
||||||
|
template<class ...Ts>
|
||||||
|
void log(Ts&&...ts){
|
||||||
|
// std::cout<<"Log: ";
|
||||||
|
// ((std::cout<<ts<<' '),...);
|
||||||
|
// std::cout<<'\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
void bfs(ll na,ll nb,ll nans,ll d){
|
||||||
|
if(d>n)return;
|
||||||
|
nans = std::max(na+nb,nans);
|
||||||
|
// log("na:",na,"nb:",nb,"nans:",nans,"ans:",ans);
|
||||||
|
if(na==1&&nb==1){
|
||||||
|
log("na:",na,"nb:",nb,"nans:",nans,"ans:",ans);
|
||||||
|
ans=std::min(ans,nans);
|
||||||
|
// log("nans:",nans);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(auto nxta:ta[na]){
|
||||||
|
for(auto nxtb:tb[nb]){
|
||||||
|
bfs(nxta,nxtb,nans,d+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(nb!=1){
|
||||||
|
for(auto nxta:ta[na]){
|
||||||
|
bfs(nxta,nb,nans,d+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(na!=1){
|
||||||
|
for(auto nxtb:tb[nb]){
|
||||||
|
bfs(na,nxtb,nans,d+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
std::cin>>T;
|
||||||
|
while(T--){
|
||||||
|
ans=std::numeric_limits<ll>::max();
|
||||||
|
std::cin>>n;
|
||||||
|
ta.resize(n+1,std::vector<ll>());
|
||||||
|
tb.resize(n+1,std::vector<ll>());
|
||||||
|
for(ll i=1;i<n;i++){
|
||||||
|
ll u,v;
|
||||||
|
std::cin>>u>>v;
|
||||||
|
ta[u].push_back(v);
|
||||||
|
ta[v].push_back(u);
|
||||||
|
}
|
||||||
|
for(ll i=1;i<n;i++){
|
||||||
|
ll u,v;
|
||||||
|
std::cin>>u>>v;
|
||||||
|
tb[u].push_back(v);
|
||||||
|
tb[v].push_back(u);
|
||||||
|
}
|
||||||
|
ll sa{},sb{};
|
||||||
|
std::cin>>sa>>sb;
|
||||||
|
// std::set<ll> visa,visb;
|
||||||
|
// visa.insert(sa);
|
||||||
|
// visb.insert(sb);
|
||||||
|
bfs(sa,sb,0, 0);
|
||||||
|
std::cout<<ans<<'\n';
|
||||||
|
}
|
||||||
|
}
|
1
src/7/21/mod1.ans
Normal file
1
src/7/21/mod1.ans
Normal file
@ -0,0 +1 @@
|
|||||||
|
2
|
3
src/7/21/mod1.in
Normal file
3
src/7/21/mod1.in
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
2 4
|
||||||
|
0 1
|
||||||
|
2 3
|
1
src/7/21/mod2.ans
Normal file
1
src/7/21/mod2.ans
Normal file
@ -0,0 +1 @@
|
|||||||
|
4851491
|
3
src/7/21/mod2.in
Normal file
3
src/7/21/mod2.in
Normal file
File diff suppressed because one or more lines are too long
1
src/7/21/mod3.ans
Normal file
1
src/7/21/mod3.ans
Normal file
@ -0,0 +1 @@
|
|||||||
|
2597588
|
3
src/7/21/mod3.in
Normal file
3
src/7/21/mod3.in
Normal file
File diff suppressed because one or more lines are too long
1
src/7/21/mod4.ans
Normal file
1
src/7/21/mod4.ans
Normal file
@ -0,0 +1 @@
|
|||||||
|
33761016
|
3
src/7/21/mod4.in
Normal file
3
src/7/21/mod4.in
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user