首页 > 其他分享 >Codeforces Round #656 (Div. 3)

Codeforces Round #656 (Div. 3)

时间:2023-02-03 11:34:30浏览次数:44  
标签:cnt minn int Codeforces else 656 maxn Div sd


A. Three Pairwise Maximums

题意:

给你三个正整数 Codeforces Round #656 (Div. 3)_数组Codeforces Round #656 (Div. 3)_数组_02,请你找到正整数 Codeforces Round #656 (Div. 3)_数组_03Codeforces Round #656 (Div. 3)_数组_04 ,使得 Codeforces Round #656 (Div. 3)_数组_05,或者确定不可能找到这样的 Codeforces Round #656 (Div. 3)_数组_03Codeforces Round #656 (Div. 3)_数组_04

AC代码:

int main()
{
int t;
sd(t);
while (t--)
{
int x, y, z;
sddd(x, y, z);
int maxn = max(x, max(y, z)), minn = min(x, min(y, z));
if (x == y && x == maxn)
{
puts("YES");
pddd(maxn, minn, minn);
}
else if (x == z && x == maxn)
{
puts("YES");
pddd(minn, maxn, minn);
}
else if (y == z && y == maxn)
{
puts("YES");
pddd(minn, minn, maxn);
}
else
puts("NO");
}
return 0;
}

B. Restore the Permutation by Merger

题意:

有一种排列 Codeforces Round #656 (Div. 3)_数组_08,将第二个 Codeforces Round #656 (Div. 3)_数组_08 的元素插入到第一个保持相对顺序的元素中,结果是长度为Codeforces Round #656 (Div. 3)_数组_10 的序列 Codeforces Round #656 (Div. 3)_数组_11,现给你插入后的序列 Codeforces Round #656 (Div. 3)_数组_11,请你求出原序列 Codeforces Round #656 (Div. 3)_数组_08

记录每个元素出现的次数,顺序输出每次减去 Codeforces Round #656 (Div. 3)_数组_14 ,判断剩下的是否满足大于等于 Codeforces Round #656 (Div. 3)_数组_14

AC代码:

const int N = 1e5 + 50;
int n, m;
int a[N];
int cnt[100];
int main()
{
int t;
sd(t);
while (t--)
{
sd(n);
mem(cnt, 0);
rep(i, 1, 2 * n)
{
sd(a[i]);
cnt[a[i]]++;
}
rep(i, 1, 2*n)
{
if (cnt[a[i]] >= 2)
{
printf("%d ", a[i]);
cnt[a[i]] -= 2;
}
}
printf("\n");
}
return 0;
}

C. Make It Good

题意:

如果能通过以下操作,从数组 Codeforces Round #656 (Div. 3)_数组_16 中获得一个非递减的数组 Codeforces Round #656 (Div. 3)_数组_04 ,则成数组 Codeforces Round #656 (Div. 3)_数组_16 为好。选择 Codeforces Round #656 (Div. 3)_数组_16 的第一个或最后一个元素,将其从 Codeforces Round #656 (Div. 3)_数组_16 中删除,并将其附加到数组 Codeforces Round #656 (Div. 3)_数组_04

从后向前找一个连续的非减然后非增序列长度即可。

AC代码:

const int N = 1e5 + 50;
int n, m;
int a[N];
int cnt[100];
int main()
{
int t;
sd(t);
while (t--)
{
sd(n);
rep(i, 1, n)
sd(a[i]);
int cnt1 = 1, pos = -1, cnt2 = 0;
per(i, 1, n - 1)
{
if (a[i] >= a[i + 1])
cnt1++;
else
{
pos = i;
break;
}
}
if (pos != -1)
{
cnt2 = 1;
per(i, 1, pos - 1)
{
if (a[i] <= a[i + 1])
cnt2++;
else
break;
}
}
pd(n - cnt2 - cnt1);
}
return 0;
}


标签:cnt,minn,int,Codeforces,else,656,maxn,Div,sd
From: https://blog.51cto.com/u_15952369/6035730

相关文章

  • Codeforces Round #655 (Div. 2)
    AOmkarandCompletion只要找两个相加不等的数交叉构造即可。AC代码:intmain(){intt;sd(t);while(t--){sd(n);rep(i,1,n){if(i&1)......
  • Codeforces 1360 D. Buying Shovels
    题意:要买个铲子,商店中有中不同的卖法,依次每一次卖到个铲子,现在只能选择其中的一种买法,问最少买几次同一种的买法,使得刚好买到直接选择小于的AC代码:intn,m,k;......
  • Codeforces 1360 E. Polygon
    题意:在一个的网格上方和左边都有一排大炮,每次可以发射一个,遇到边界和都会停下来,有没有一种发射频率可以组成给出的大炮的位置在左和上,所以每个非右边界或者下边界的......
  • Codeforces 1358 C. Celex Update
    题意:一个矩形内有多个方格,每个方格都按照顺序填写了一些数。给两个坐标,求这两个坐标间路径经过的数字和不同的路线总数。可以看出比如要从走到,这两种走法和第二个比......
  • Codeforces 1354 D. Multiset(树状数组)
    题意;要你实现一个求第k大数的数据结构。树状数组模板题。AC代码:constintN=1e6+50;inta[N];intn,q;voidadd(intp,intval){while(p<=n){a[p]+=va......
  • codeforces 580C Kefa and Park (树上DFS)
    Description:Kefadecidedtocelebratehisfirstbigsalarybygoingtotherestaurant.Helivesbyanunusualpark.Theparkisarootedtreeconsistingof n ve......
  • CodeForces - 253E Table with Letters - 2
    Description:Let'sconsideranetworkprinterthatfunctionslikethat.Itstartsworkingattime0.Ineachseconditcanprintonepageofatext.Atsomemomen......
  • Codeforces1201 B Maximum Median (二分)
    Description:Youaregivenanarray aa of nn integers,where nn isodd.Youcanmakethefollowingoperationwithit:Chooseoneoftheelementsofthearray......
  • Codeforces Round #596 D
    找到a[i]*a[j]=x^k符合这个式子的有多少种组合。分解质因子来做就行了AC代码:#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<s......
  • Codeforces-343D Water Tree(树链剖分)
    Description:MadscientistMikehasconstructedarootedtree,whichconsistsof n vertices.Eachvertexisareservoirwhichcanbeeitheremptyorfilledw......