rated

EC Round 41 (Rated for Div. 2)主席树 E. Tufurama

寵の児 提交于 2019-11-28 18:42:37
简单分析一下,对于x<y,求a[x]>=y 同时a[y]>=x 再简化一下,求1-a[y]区间内大于>=y的个数。。。主席树牛逼 #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> #include<vector> #define LL long long using namespace std; const int maxx = 2e5+6; struct node{ int l,r; int cnt; }tree[maxx*40]; int a[maxx]; int b[maxx]; int root[maxx]; int cnt; vector<int>v; int getval(int x){ return lower_bound(v.begin(),v.end(),x)-v.begin()+1; } void inserts(int l,int r,int pre,int &now,int pos){ now=++cnt; tree[now]=tree[pre]; tree[now].cnt++; if(l==r){ return ; } int mid=(l+r)>>1; if (pos<=mid){ inserts(l,mid,tree[pre].l,tree[now]

Educational Codeforces Round 71 (Rated for Div. 2)

一曲冷凌霜 提交于 2019-11-28 18:05:44
Solution A. There Are Two Types Of Burgers 题意: 做一个 \(A\) 需要两个 \(b\) 和两个 \(p\) ,能卖 \(h\) 元;做一个 \(B\) 需要两个 \(b\) 和两个 \(f\) ,能卖 \(c\) 元。给出 \(b,p,f\) 的数量,求最多卖多少元。 思路: 比赛的时候用循环搞了,判断 \(h,c\) 的大小关系,决定先做什么。也可以 \(b=b/2\) ,然后判断大小,每次取最小值,利润直接算,然后更新 \(b\) ,再进行一次。 //#define DEBUG #include<bits/stdc++.h> using namespace std; #define lson (rt<<1) #define rson (rt<<1|1) const int N=100010; const int inf=0X3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const double eps = 1e-6; const double pi = acos(-1.0); const int mod = 1000000007; typedef long long ll; int main() { #ifdef DEBUG freopen("in.txt","r"

Educational Codeforces Round 60 (Rated for Div. 2)(ABC)

懵懂的女人 提交于 2019-11-28 14:53:52
A. Best Subsegment 题意:给你一组数字,让你找到最长且平均数最大且没有小数的长度 解:平均数最大,直接找最大值,然后找最大值的长度(注意处理最后一个) #include <bits/stdc++.h> using namespace std; const int maxn=1e5+10; typedef long long ll; int a[maxn]; int main(){ int n; cin>>n; int maxx=-1; for(int i=1;i<=n;i++){ cin>>a[i]; maxx=max(maxx,a[i]); } int ans=1; int cnt=0; for(int i=1;i<=n;i++){ if(a[i]==maxx&&a[i+1]==maxx&&i!=n){ cnt++; } else{ if(a[i]==a[i-1])cnt++; ans=max(cnt,ans); cnt=0; } //cout<<cnt<<endl; } cout<<ans<<endl; return 0; } View Code B. Emotes 题意:n个数,让你找出m个数,使得和最大,每个数可以重复选择,最多选择k次; 解:排序,选k个最大+1个次大搭配; #include <bits/stdc++.h> using namespace

Educational Codeforces Round 71 (Rated for Div. 2)

放肆的年华 提交于 2019-11-28 11:33:31
A. There Are Two Types Of Burgers 思路:签到题,价格高的先做就行。 AC代码: 1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 std::ios::sync_with_stdio(false); 6 int t; 7 cin >> t; 8 int b,p,f; 9 int h, c; 10 while(t--) 11 { 12 cin >> b >> p >> f; 13 cin >> h >> c; 14 b /= 2; 15 int ans = 0; 16 if(h > c) 17 { 18 while(p && b) 19 { 20 ans += h; 21 p--; 22 b--; 23 } 24 while(f && b) 25 { 26 ans += c; 27 f--; 28 b--; 29 } 30 } 31 else{ 32 while(f && b) 33 { 34 ans += c; 35 f--; 36 b--; 37 } 38 while(p && b) 39 { 40 ans += h; 41 p--; 42 b--; 43 } 44 } 45 cout << ans << endl; 46 } 47 return 0; 48 }

Educational Codeforces Round 59 (Rated for Div. 2)(ABCD)

限于喜欢 提交于 2019-11-28 11:09:59
A. Digits Sequence Dividing 题意:给你一个数字串,只包含1-9,让你至少分成两段,使得每一段的数字大于前一段的数字; 解:对n特判,如果n为2,那么比较一下两个数字大小,如果n>2,那么就可以直接分成两部分,第一部分1个数字,剩下都为第二部分; #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1e3+10; const int mod=998244353; ll ans[maxn]; int main(){ int T; cin>>T; while(T--){ int n; string s; cin>>n>>s; if(n==2){ if(s[0]<s[1]){ cout<<"YES"<<endl; cout<<"2"<<endl; cout<<s[0]<<' '<<s[1]<<endl; } else cout<<"NO"<<endl; } else { cout<<"YES"<<endl; cout<<"2"<<endl; cout<<s[0]<<' '; for(int i=1;i<n;i++)cout<<s[i]; cout<<endl; } } return 0; } View Code B. Digital root 题意

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

风流意气都作罢 提交于 2019-11-28 10:55:00
原文链接: https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is sorted in non-descending order by first elements or if it is sorted in non-descending order by second elements. Otherwise the sequence is good. There are examples of good and bad sequences: s=[(1,2),(3,2),(3,1)] is bad because the sequence of first elements is sorted: [1,3,3]; s=[(1,2),(3,2),(1,2)] is bad because the sequence of second elements is

Educational Codeforces Round 71 (Rated for Div. 2) C - Gas Pipeline

醉酒当歌 提交于 2019-11-28 10:10:35
原文链接: https://www.cnblogs.com/xwl3109377858/p/11404321.html Educational Codeforces Round 71 (Rated for Div. 2) C - Gas Pipeline You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment [0,n] on OX axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval (x,x+1) with integer x. So we can represent the road as a binary string consisting of n characters, where character 0 means that current interval doesn't contain a crossroad, and 1 means that there is a crossroad. Usually, we can

Educational Codeforces Round 71 (Rated for Div. 2) B - Square Filling

北战南征 提交于 2019-11-28 10:08:23
原文链接: https://www.cnblogs.com/xwl3109377858/p/11404261.html Educational Codeforces Round 71 (Rated for Div. 2) B - Square Filling You are given two matrices A and B. Each matrix contains exactly n rows and m columns. Each element of A is either 0 or 1; each element of B is initially 0. You may perform some operations with matrix B. During each operation, you choose any submatrix of B having size 2×2, and replace every element in the chosen submatrix with 1. In other words, you choose two integers x and y such that 1≤x<n and 1≤y<m, and then set Bx,y, Bx,y+1, Bx+1,y and Bx+1,y+1 to 1. Your goal

Educational Codeforces Round 71 (Rated for Div. 2) A - There Are Two Types Of Burgers

做~自己de王妃 提交于 2019-11-28 10:00:52
本文链接: https://www.cnblogs.com/xwl3109377858/p/11404050.html Educational Codeforces Round 71 (Rated for Div. 2) A - There Are Two Types Of Burgers There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet. You have b buns, p beef patties and f chicken cutlets in your restaurant. You can sell one hamburger for h dollars and one chicken burger for c dollars. Calculate the maximum profit you can achieve. You have to answer t independent queries.

Educational Codeforces Round 71 [Rated for Div. 2]

雨燕双飞 提交于 2019-11-28 07:53:58
A There Are Two Types Of Burgers 传送门 简单的分类讨论而已 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #define ll long long using namespace std; const int maxn=1e6+5; int main(){ int t; cin>>t; while(t--){ int b,p,f; cin>>b>>p>>f; int h,c; cin>>h>>c; int con=b/2; if(con<=min(p,f)){//面包少的话 if(h>=c){//牛肉贵,买牛肉 printf("%d\n",con*h); }else{ printf("%d\n",con*c); } }else{//面包够的话 if(h>=c){//牛肉贵,先买牛肉 if(con>=p){//大于牛肉的数,牛肉全卖加鸡肉 if(con>=(p+f)){ printf("%d\n",h*p+f*c); }else{ printf("%d\n",h*p+(con-p)*c); //printf("aa\n"); } }else{//全卖牛肉 printf("%d\n",con*h); //printf("aa\n"); }