浙江省赛真题2018
A - Peak
题意:就是给你一个序列让你判断是不是先增加后减少的,签到;
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<bits/stdc++.h> using namespace std; #define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++) #define per(i,j,k) for(int i=(int)k;i>=(int)j;i--) #define pb push_back #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef long double ldb; ll a[100005]; int main(){ int t,n; scanf("%d",&t); while(t--){ scanf("%d",&n); int flag=1; int max=-1,maxi; for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); if(a[i]>max){ max=a[i]; maxi=i; } } if(maxi==n||maxi==1)flag=0; for(int i=1;i<maxi;i++){ if(a[i]>=a[i+1]){ flag=0; break; } } for(int i=maxi+1;i<=n;i++){ if(a[i-1]<=a[i]){ flag=0; break; } } if(flag)printf("Yes\n"); else printf("No\n"); } return 0; }
B - King of Karaoke
题意:就是两个数列做个差,取个众数;我用map做的取众数;
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<bits/stdc++.h> using namespace std; #define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++) #define per(i,j,k) for(int i=(int)k;i>=(int)j;i--) #define pb push_back #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef long double ldb; const int N=1e5+5; int d[N],s[N],ans[N]; int main(){ int t,n; scanf("%d",&t); while(t--){ scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&d[i]); map<int,int>mp; for(int i=1;i<=n;i++){ scanf("%d",&s[i]); ans[i]=s[i]-d[i]; mp[ans[i]]++; } map<int,int>::iterator it; int cnt=-1; for(it=mp.begin();it!=mp.end();it++){ if(it->se>cnt)cnt=it->se; } printf("%d\n",cnt); } return 0; }
J - CONTINUE...?
题意:就是给你让你构造一个数列,感觉瞎出的题目,怎么构造都可以,这个最开始没有想到,
解法:先判断sum%2是否为1,然后从后往前分配即可;
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<bits/stdc++.h> using namespace std; #define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++) #define per(i,j,k) for(int i=(int)k;i>=(int)j;i--) #define pb push_back #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef long double ldb; int ans[500000]; int main(){ int n,t; scanf("%d",&t); while(t--){ scanf("%d",&n); string s; cin>>s; ll sum=n*1ll*(n+1)/2; if(sum%2)printf("-1\n"); else { sum/=2; for(int i=n-1;i>=0;i--){ if(sum>i)sum-=i+1,ans[i]=(s[i]=='1')?4:2; else ans[i]=(s[i]=='1')?3:1; } for(int i=0;i<n;i++)printf("%d",ans[i]); printf("\n"); } } return 0; }
L - Doki Doki Literature Club
题意:就是排序,不看数据范围,相乘会爆int,然后就可以过了;
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<bits/stdc++.h> using namespace std; #define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++) #define per(i,j,k) for(int i=(int)k;i>=(int)j;i--) #define pb push_back #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef long double ldb; struct word{string s;ll w;}a[500]; bool cmp(word a,word b){if(a.w!=b.w)return a.w>b.w;else return a.s<b.s;} int main(){ int t,n,m; scanf("%d",&t); while(t--){ cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i].s>>a[i].w; sort(a+1,a+1+n,cmp); ll ans=0; for(int i=1;i<=m;i++)ans+=(m-i+1)*a[i].w*1ll; printf("%lld ",ans); for(int i=1;i<=m;i++){ cout<<a[i].s; if(i==m)printf("\n"); else printf(" "); } } return 0; }
M - Lucky 7
签到;
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<bits/stdc++.h> using namespace std; #define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++) #define per(i,j,k) for(int i=(int)k;i>=(int)j;i--) #define pb push_back #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef long double ldb; int a[1000]; int main(){ int t,n,b; scanf("%d",&t); while(t--){ scanf("%d%d",&n,&b); int flag=0; for(int i=1;i<=n;i++){ scanf("%d",&a[i]); if((a[i]+b)%7==0)flag=1; } if(flag)printf("Yes\n"); else printf("No\n"); } return 0; }
未完待续;
想的太多,做的太少;