码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #656 (Div. 3)

时间:2020-07-18 11:29:01      阅读:89      评论:0      收藏:0      [点我收藏+]

标签:round   maximums   rest   merge   long   div   problem   int   perm   

Three Pairwise Maximums

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+3;
typedef long long ll;
const ll inf=1e18;
ll a[N],b[N];
int main()
{
    int t;cin>>t;
    while(t--)
    {
        int x,y,z;
        cin>>x>>y>>z;
        if(x==y&&x==z)
        {
            printf("YES\n");
            printf("%d %d %d\n",x,x,x);
        }
        else if(x==y)
        {
            if(z<x)
            {printf("YES\n");
                printf("%d %d %d\n",x,z,z);
            }
            else printf("NO\n");
        }
        else if(y==z)
        {
            if(x<z)
            {printf("YES\n");
                printf("%d %d %d\n",z,x,x);
            }
            else printf("NO\n");
        }
        else if(x==z)
        {
            if(y<x)
            {printf("YES\n");
                printf("%d %d %d\n",x,y,y);
            }
            else printf("NO\n");
        }
        else printf("NO\n");
    }
}

Make It Good

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+3;
typedef long long ll;
const ll inf=1e18;
ll a[N],b[N];
int main()
{
  int t;cin>>t;
  while(t--)
  {
      int n,r=0;cin>>n;
      for(int i=1;i<=n;i++)
      {
          cin>>a[i];
      }
 
         int i=1,ans=1;
          if(a[i+1]>=a[i])
          {
              while(a[i+1]>=a[i]&&i>1)
              {
                  i++;
                  ans++;
              }
              while(a[i+1]<=a[i]&&i>1)
              {
                  i++;
                  ans++;
              }
              r=max(ans,r);
          ans=1;
          }
          else if(a[i+1]<=a[i])
          {
              while(a[i+1]<=a[i]&&i>1)
              {
                  i++;
                  ans++;
              }
          }
          r=max(ans,r);
            i=n,ans=1;
          if(a[i-1]>=a[i])
          {
              while(a[i-1]>=a[i]&&i>1)
              {
                  i--;
                  ans++;
              }
              while(a[i-1]<=a[i]&&i>1)
              {
                  i--;
                  ans++;
              }
              r=max(ans,r);
          ans=1;
          }
          else if(a[i-1]<=a[i])
          {
              while(a[i-1]<=a[i]&&i>1)
              {
                  i--;
                  ans++;
              }
          }
          r=max(ans,r);
      printf("%d\n",n-r);
 
  }
}

Restore the Permutation by Merger

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+3;
typedef long long ll;
const ll inf=1e18;
ll a[N],b[N];
int main()
{
  int t;cin>>t;
  while(t--)
  {
      int n;cin>>n;
      for(int i=1;i<=2*n;i++)
      {
          cin>>a[i];
          b[a[i]]++;
          if(b[a[i]]%2==0) printf("%d ",a[i]);
      }
          printf("\n");
  }
}

 

Codeforces Round #656 (Div. 3)

标签:round   maximums   rest   merge   long   div   problem   int   perm   

原文地址:https://www.cnblogs.com/hahaee/p/13334617.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!