牛客周赛52

A.[两数之和](https://atcoder.jp/contests/abc365/tasks/abc365_a)

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#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);
   // int t;
   // cin>>t;
   // while(t--)
      Miraitowa();
     return 0;
};


B.[ 小红装匣子](https://atcoder.jp/contests/abc365/tasks/abc365_b)

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#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)

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#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);
   // int t;
   // cin >> t;
   // while (t--)
   Miraitowa();
   return 0;
};

D. 小红的最大字典序

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#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);
   // int t;
   // cin>>t;
   // while(t--)
   Miraitowa();
   return 0;
};

E.小红的图上加边

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#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);
   // int t;
   // cin>>t;
   // while(t--)
      Miraitowa();
     return 0;
};


  • 10
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值