rated

Educational Codeforces Round 75 (Rated for Div. 2) D. Salary Changing

时光毁灭记忆、已成空白 提交于 2019-12-03 06:43:02
链接: https://codeforces.com/contest/1251/problem/D 题意: You are the head of a large enterprise. n people work at you, and n is odd (i. e. n is not divisible by 2). You have to distribute salaries to your employees. Initially, you have s dollars for it, and the i-th employee should get a salary from li to ri dollars. You have to distribute salaries in such a way that the median salary is maximum possible. To find the median of a sequence of odd length, you have to sort it and take the element in the middle position after sorting. For example: the median of the sequence [5,1,10,17,6] is 6, the

Educational Codeforces Round 76 (Rated for Div. 2)

偶尔善良 提交于 2019-12-03 06:13:06
原题目链接: https://codeforces.com/contest/1257/problem/C C. Dominated Subarray 题意:如果一个数组中一个元素的个数比其他都多,且这个元素个数最少为2,求这个数组中的子数组,使得子数组也满足这样一个规律。 #include<bits/stdc++.h> using namespace std; void solve(){ int n; scanf("%d",&n); map<int,int> m; int ans=1e9; long long x; for(int i=0;i<n;i++){ cin>>x; if(m.find(x)!=m.end()){ ans=min(ans,i-m[x]+1); } m[x]=i; } if(ans==1e9)ans=-1; cout<<ans<<endl; } int main(){ int t; scanf("%d",&t); while(t--){ solve(); } } D. Yet Another Monster Killing Problem 题意: 你玩电脑游戏。在这个游戏中,你带领一群m个英雄,你必须清除一个地牢里的n个怪物。每个怪物的特点是它的力量ai。每个英雄的特点是他的权力pi和耐力si。英雄们一天天地清扫地牢。在每天的开始,你选择一个英雄(准确的一个

Educational Codeforces Round 76 (Rated for Div. 2) C题

戏子无情 提交于 2019-12-03 06:07:20
C. Dominated Subarray Let’s call an array t dominated by value v in the next situation. At first, array t should have at least 2 elements. Now, let’s calculate number of occurrences of each number num in t and define it as occ(num). Then t is dominated (by v) if (and only if) occ(v)>occ(v′) for any other number v′. For example, arrays [1,2,3,4,5,2], [11,11] and [3,2,3,2,3] are dominated (by 2, 11 and 3 respectevitely) but arrays [3], [1,2] and [3,3,2,2,1] are not. Small remark: since any array can be dominated only by one number, we can not specify this number and just say that array is either

Educational Codeforces Round 75 (Rated for Div. 2) C. Minimize The Integer

ⅰ亾dé卋堺 提交于 2019-12-03 05:04:54
链接: https://codeforces.com/contest/1251/problem/C 题意: You are given a huge integer a consisting of n digits (n is between 1 and 3⋅105, inclusive). It may contain leading zeros. You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by 2). For example, if a=032867235 you can get the following integers in a single operation: 302867235 if you swap the first and the second digits; 023867235 if you swap the second and the third digits; 032876235 if you swap the fifth and the sixth digits;

Educational Codeforces Round 75 (Rated for Div. 2) B. Binary Palindromes

寵の児 提交于 2019-12-03 05:03:30
链接: https://codeforces.com/contest/1251/problem/B 题意: A palindrome is a string t which reads the same backward as forward (formally, t[i]=t[|t|+1−i] for all i∈[1,|t|]). Here |t| denotes the length of a string t. For example, the strings 010, 1001 and 0 are palindromes. You have n binary strings s1,s2,…,sn (each si consists of zeroes and/or ones). You can swap any pair of characters any number of times (possibly, zero). Characters can be either from the same string or from different strings — there are no restrictions. Formally, in one move you: choose four integer numbers x,a,y,b such that 1≤x

Educational Codeforces Round 75 (Rated for Div. 2) A. Broken Keyboard

試著忘記壹切 提交于 2019-12-03 05:00:03
链接: https://codeforces.com/contest/1251/problem/A 题意: Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains 26 buttons (one for each letter of the Latin alphabet). Each button is either working fine or malfunctioning. To check which buttons need replacement, Polycarp pressed some buttons in sequence, and a string s appeared on the screen. When Polycarp presses a button with character c, one of the following events happened: if the button was working correctly, a character c appeared at the end of the

Educational Codeforces Round 44 (Rated for Div. 2) B - Switches and Lamps

匿名 (未验证) 提交于 2019-12-03 00:18:01
题目链接: http://codeforces.com/contest/985/problem/B 题意:每个开关控制至少一个台灯,多个开关同时按下不会使台灯从亮变暗再变亮,保证按下所有开关后所有台灯都会亮。 输出是否存在这样一个开关,去掉它后利用剩下的开关仍然能点亮所有台灯。 题解:我们要寻找不是独一无二的开关,那就先统计每个台灯被多少个开关管,记录在vis【】中。然后遍历每个开关,看这个开关是否是某个台灯的独一无二(独一无二的意思是,如果去掉了这个开关,这盏台灯就绝对无法点亮)。如果这个开关不是独一无二的,那就说明至少存在一个符合题意的可以去掉的开关,输出“YES”,找不到,就输出“NO” 代码: #include <iostream> #include <algorithm> #include <cstring> #include <cmath> #define N 2005 //一个开关可能可以开多个台灯 //如果开关对于其中一盏台灯是独一无二的,这个开关就不在考虑范围内 //如果有一个开关不是独一无二,就决定可以是它了,输出yes using namespace std; char an[N][N]; int vis[N]; int main() { int row,col,flag; cin>>row>>col; memset(vis,0,sizeof(vis));

Educational Codeforces Round 75 (Rated for Div. 2) B题

匿名 (未验证) 提交于 2019-12-03 00:15:02
B. Binary Palindromes time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You have n binary strings s1,s2,…,sn (each si consists of zeroes and/or ones). You can swap any pair of characters any number of times (possibly, zero). Characters can be either from the same string or from different strings ― there are no restrictions. Formally, in one move you: choose four integer numbers x,a,y,b such that 1≤x,y≤n and 1≤a≤|sx| and 1≤b≤|sy| (where x and y are string indices and a and b are positions in strings sx and sy respectively), swap (exchange)

Educational Codeforces Round 67 (Rated for Div. 2)B. Letters Shop

匿名 (未验证) 提交于 2019-12-03 00:11:01
Educational Codeforces Round 67 (Rated for Div. 2)B. Letters Shop 题意 :找到从头开始最短的串,使得串的字母个数涵盖给出子串所有字母的个数 做法 :一开始直接暴力计数加查找,后来TLE了才想到用二分。。。我真的是傻了 # include <cstdio> # include <cstring> # include <algorithm> # include <iostream> # include <string> # include <vector> # include <stack> # include <bitset> # include <cstdlib> # include <cmath> # include <set> # include <list> # include <deque> # include <queue> # include <map> # define ll long long # define pb push_back # define rep ( x , a , b ) for ( int x = a ; x <= b ; x ++) # define repp ( x , a , b ) for ( int x = a ; x < b ; x ++) # define W ( x

Educational Codeforces Round 72 (Rated for Div. 2) A. Creating a Character

匿名 (未验证) 提交于 2019-12-02 23:59:01
题目原文: http://codeforces.com/contest/1217/problem/A 题意:三个数a,b,c。。将c分配到a,b中,要分完。分完后a要严格大于b。有几种分法。 我的思路(菜菜鸟思路):分情况,a+c<=b,b>=a,剩下的a-b如果大于c,直接输出c+1,否则找到能够分给b最大的数即可。 AC代码 1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 typedef long long ll; 5 int main(){ 6 int T; 7 cin>>T; 8 while(T--){ 9 ll a,b,c; 10 cin>>a>>b>>c; 11 ll num; 12 if(a+c<=b){ 13 cout<<"0"<<endl; 14 continue; 15 } 16 if(b>=a){ 17 num=b-a+1; 18 c-=num; 19 cout<<c/2+1<<endl; 20 } 21 else{ 22 num=a-b; 23 ll ans; 24 if(num>c){ 25 cout<<c+1<<endl; 26 continue; 27 } 28 ans=c-(c-num)/2; 29 cout<<ans<<endl; 30 } 31 } 32