Codeforces 435B. Pasha Maximizes】的更多相关文章

简单贪心.... B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he shoul…
题目链接: [传送门][1] Pasha Maximizes time limit per test:1 second     memory limit per test:256 megabytes Description Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortu…
题目链接:http://codeforces.com/problemset/problem/435/B 题目意思:给出一个最多为18位的数,可以通过对相邻两个数字进行交换,最多交换 k 次,问交换 k 次之后,这个数最大可以变成多少. 不知道最近是不是疏于训练(一直研究百度之星的题目,最终决定就是暂时放下,可能能力还没达到做那种题目的水平,不过都好感谢乌冬兄耐心甘为我解答左两道题目),昨晚又想学学拓扑排序(SPFA提到),结果没看明白= =...再加上昨晚比赛...电脑卡机卡得要命,于是悲催了=…
看到题目的时候,以为类似插入排序,比较第i个元素和第i-1个元素, 如果第i个元素比第i-1个元素小,则不交换 如果第i个元素比第i-1个元素大,则交换第i个元素和第i-1个元素 继续比较第i-1个元素与前一个元素,直到前一个元素大为止 交换元素次大于等于k则停止 但对测试用例 1234 3 则出现问题,如果按照上述方法得到答案为3214, 但正确答案是4321,直接将第4个元素往前交换 故在上面基础上改进得 当扫描第i个元素时,则要取出[i,i+k+1)之间的最大元素,然后将最大元素往前交换,…
题意:给出一串数字,给出k次交换,每次交换只能交换相邻的两个数,问最多经过k次交换,能够得到的最大的一串数字 从第一个数字往后找k个位置,找出最大的,往前面交换 有思路,可是没有写出代码来---sad #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<ma…
题目链接:http://codeforces.com/problemset/problem/557/B 题目意思:有 2n 个茶杯,规定第 i 个茶杯最多只能装 ai 毫升的水.现在给出 w 毫升的水,需要把这 w 毫升(可以不用光)的水倒入到这 2n 个茶杯中,使得分给 n 个男的每个水杯的水恰好是 n 个女的2倍(注意,n 个男的水杯装的水是一样的,n 个女也是).现在问的是,怎样使得 2n 个杯装的水最多,求出这个值. ***********************************…
595B - Pasha and Phone 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back ; const int INF=0x3f3f3f3f; ; ll a[N]; int b[N]; ]={}; int main() { ios::sync_with_stdio(false); cin.tie(); int n,k; cin>>n>&g…
B. Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consis…
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string. Pasha didn't like his present…
题意:给定一个长度为len的字符序列,然后是n个整数,对于每一个整数ai, 将字符序列区间为[ai,len-ai+1]进行反转.求出经过n次反转之后的序列! /* 思路1:将区间为偶数次的直接去掉!对剩下的区间进行反转.超时了,智商上的压制... */ #include<iostream> #include<cstdio> #include<algorithm> #include<stack> #include<cstring> #include…
题意就是一次次翻转字符串 然后输出最终的字符串 暴力一发O(n*m)果然超时了 因为每次翻转的的都是a-1到对称位置 所以一个位置翻转两次等于没有操作 所以只需要记录一下len/2的位置前的操作次数 O(len/2)…… #include<stdio.h> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<string>…
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int n,ans; int main() { while(~scanf("%d",&n)){ ans=; !=)ans=; -)/; printf("%d\n",ans); } ; }…
题意:只能对相邻的两个数字进行交换,允许k次交换,输出交换能得到的最大的数.从最高位开始寻找最优,每次寻找能交换的步数里交换到的最大值进行交换. #include<cstdio> #include<cstring> #include<iostream> using namespace std; ]; int main() { int k; scanf("%s%d",num,&k); int len=strlen(num); ;i<len…
B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it…
Pasha and String CodeForces - 525B Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given str…
A. Pasha and Stick 题目连接: http://www.codeforces.com/contest/610/problem/A Description Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive…
B. Pasha and Tea Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/problem/B Description Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and…
B. Pasha and Phone Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/problem/B Description Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of ex…
Codeforces Round #297 (Div. 2)B. Pasha and String Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/B Description Pasha got a very beautiful string s for his birthday, the string consists o…
题目传送门 /* 题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果 字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录 每个转换的次数,把每次要反转的反转就不超时了:) */ #include <cstdio> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN]; i…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups,…
B. Pasha and PhonePasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a1, …
A. Pasha and Stick   Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be n.…
B. Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consis…
B. Pasha and Tea time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w millilit…
B. Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consis…
[题目链接]:http://codeforces.com/contest/508/problem/A [题意] 让你在一个n*m的方格上给方格染色; 顺序给出染色的k个格子 如果在某一时刻 有一个2*2长方形; 输出是第几个格子; [题解] 在染色的时候; 判断一下这是4个方格中的哪一个 左上角or右上角or左下角or右下角 然后看看另外3个格子有没有被染色; 有的话就结束; [Number Of WA] 0 [完整代码] #include <bits/stdc++.h> using name…
B. Pasha and Phone   Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a…
题目传送门 /* 模拟水题:给定n*m的空白方格,k次涂色,将(x,y)处的涂成黑色,判断第几次能形成2*2的黑色方格,若不能,输出0 很挫的判断四个方向是否OK */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <map> using namespace std; ; c…
题 题意 总共有 w 克蛋糕,2n 个盘子,第 i 个盘子容量为 ai ,n 个女孩和 n 个男孩,男孩得到的是女孩得到的蛋糕的两倍,求他们得到蛋糕的最大值. 分析 把盘子从小到大排序,然后 女生得到的蛋糕总量是 n*min(最小的盘子,第n+1小的盘子/2,w/(3n)). 答案就是女生得到的蛋糕的3倍. 代码 #include<cstdio> #include<algorithm> using namespace std; int n,a[1000005]; double w,…