标签:round maximums rest merge long div problem int perm
#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"); } }
#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