打得最烂一场Codeforces,多次都错题,无限WA。。。

A题:

题意:给定n个橘子的大小,大小超过b的丢掉,不足d的补充进来,同时超过d的部分去掉,问要去掉几次

分析:直接模拟即可

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int maxn=;
int a[maxn];
int n,b,d;
int main()
{
while(cin>>n>>b>>d)
{
for(int i=;i<n;i++)
scanf("%d",&a[i]);
vector<int> que;
for(int i=;i<n;i++)
{
if(a[i]<=b)
que.push_back(a[i]);
}
queue<int> q;
while(!q.empty())
q.pop();
int cnt=;
for(int i=;i<que.size();i++)
{
int t=que[i];
q.push(t);
}
while(!q.empty())
{
int h=q.front();
q.pop();
while(h<=d)
{
if(q.empty()) break;
int f=q.front();
q.pop();
h+=f;
if(h>d)
{
cnt++;
break;
}
}
}
cout<<cnt<<endl;
}
return ;
}

B题:

题意:给定n个点的坐标,同时给定一个点的坐标,求这个点到达其中n-1个点的最短路径

分析:因为必将到达a[n-1]或者a[0],所以我们先将n个点的坐标进行排序,然后比较覆盖a[n-1]和a[0]的所有情况下的最小值,注意n=1的时候结果为0

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int maxn=;
int a[maxn];
int n,d;
int main()
{
while(cin>>n>>d)
{
for(int i=;i<n;i++)
scanf("%d",&a[i]);
if(n==){
cout<<""<<endl;
continue;
}
sort(a,a+n);
int h=<<;
int cnt=<<;
if(d<=a[])
{
cout<<abs(a[n-]-d)<<endl;
continue;
}else if(a[n-]<=d)
{
cout<<abs(a[]-d)<<endl;
continue;
}
if(d>=a[]&&d<=a[])
{
h=abs(a[n-]-d);
}
if(d<=a[n-]&&d>=a[n-])
{
h=min(h,abs(a[]-d));
}
cnt=min(cnt,*(abs(a[]-d))+abs(a[n-]-d));
cnt=min(cnt,*(abs(a[n-]-d))+abs(a[]-d));
cnt=min(cnt,*(abs(a[n-]-d))+abs(a[]-d));
cnt=min(cnt,*(abs(a[]-d))+abs(a[n-]-d));
cout<<min(h,cnt)<<endl;
}
return ;
}

C题:

题意:给定一个字符串,然后对于其中的一个子串进行如下变化,每个字母变成它的前一个字母,a变成z,求变化以后字典序最小

分析:开始不理解字典序,后来知道就是让排在前面的数尽量小。这样就可以贪心,对于排在尽量靠前不含有a的子串进行变化,若全是a,则将最后一个a变成z即可。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
string s;
int main()
{
while(cin>>s)
{
int n=s.length();
int flag=;
for(int i=;i<n;i++)
{
if(s[i]!='a')
{
flag=;
s[i]=s[i]-;
}else if(s[i]=='a'&&flag)
{
break;
}
}
if(flag)
{
for(int i=;i<n;i++)
printf("%c",s[i]);
}else{
for(int i=;i<n-;i++)
printf("%c",s[i]);
printf("z");
}
printf("\n");
}
return ;
}

Codeforces AIM Tech Round3的更多相关文章

  1. Codeforces AIM Tech Round (Div. 2)

    这是我第一次完整地参加codeforces的比赛! 成绩 news standings中第50. 我觉这个成绩不太好.我前半小时就过了前三题,但后面的两题不难,却乱搞了1.5h都没有什么结果,然后在等 ...

  2. 【Codeforces AIM Tech Round 4 (Div. 2) C】

    ·将排序限制于子序列中,又可以说明什么呢? C. Sorting by Subsequences ·英文题,述大意:       输入一个长度为n的无重复元素的序列{a1,a2……an}(1<= ...

  3. codeforces AIM Tech Round 4 div 2

    A:开个桶统计一下,但是不要忘记k和0比较大小 #include<bits/stdc++.h> using namespace std; ]; ]; int main() { int k; ...

  4. Codeforces Aim Tech Round4 (Div2) D

    题目链接: 题意: 给你一个严格升序的单链表,但是是用数组来存放的.对于每一个位置来说,你可以知道这个位置的值和下一个的位置.你每一个可以询问一个位置,机器会告诉你这个位置的值,和下一个位置的指针.要 ...

  5. Codeforces AIM Tech Round 5 (rated, Div. 1 + Div. 2)

    A. Find Square time limit per test: 1 second memory limit per test: 256 megabytes input: standard in ...

  6. AIM Tech Round 5 1028cf(A-E)

    AIM Tech Round 5 (codeforces上题目编号是1028)(A-E) ---完全被这次比赛打击,自己真的很渣--- 战况 依旧3题选手 被构造题坑得好惨 稍稍涨了rating,希望 ...

  7. codeforce AIM tech Round 4 div 2 B rectangles

    2017-08-25 15:32:14 writer:pprp 题目: B. Rectangles time limit per test 1 second memory limit per test ...

  8. AIM Tech Round 3 (Div. 2) (B C D E) (codeforces 709B 709C 709D 709E)

    rating又掉下去了.好不容易蓝了.... A..没读懂题,wa了好几次,明天问队友补上... B. Checkpoints 题意:一条直线上n个点x1,x2...xn,现在在位置a,求要经过任意n ...

  9. AIM Tech Round (Div. 2) D. Array GCD dp

    D. Array GCD 题目连接: http://codeforces.com/contest/624/problem/D Description You are given array ai of ...

随机推荐

  1. 笨方法学python--数字和数学计算

    1 数学运算符号 + plus 加号 - minus 减号 / slash 除法 * asterisk 乘法 % percent 模除 求余 < less than 小于号 > great ...

  2. C#中使用正则表达式提取超链接地址的集中方法

    一般在做爬虫或者CMS的时候经常需要提取 href链接或者是src地址.此时可以使用正则表达式轻松完成. Regex reg = new Regex(@"(?is)<a[^>]* ...

  3. Log4j 简介及初步应用

    使用2.5版本有问题,暂时没有解决,也许是JDK版本不兼容的原因.因此使用的是log4j-1.2.8.jar 1.三个组件 日志记录器  ——  Logger.输出目的地 —— Appender.输出 ...

  4. 转 如何不耍流氓的做运维之——SHELL脚本

    家都是文明人,尤其是做运维的,那叫一个斯文啊.怎么能耍流氓呢?赶紧看看,编写 SHELL 脚本如何能够不耍流氓. 下面的案例,我们以 MySQL 数据库备份 SHELL 脚本的案例来进行阐述. 不记录 ...

  5. POJ 1182 食物链 经典并查集+关系向量简单介绍

    题目: 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种. 有 ...

  6. jsp环境搭建(Windows)

    1.软件准备 JDK 最新版jdk-8u45-windows-x64.exe tomcat 最新版32-bit/64-bit Windows Service Installer Eclipse IDE ...

  7. Drawcli分析

    当前环境:windows7 32位旗舰版.VS2010旗舰版 Drawcli介绍: Drawcli是VS2010中的一个示例程序,能够进行简单的绘图操作,例如线.矩形.圆角矩形.多边形等,位于VS安装 ...

  8. 青蛙的约会<数论,extgcd>

    青蛙的约会 题意: 在一个圆上有一个零刻度点,公青蛙和母青蛙分别在A点和B点<不同的位 置>,他们每秒行走的距离分别是m和n,圆的周长是L.问题是这两个青 蛙能不能相遇,若能在什么时候相遇 ...

  9. 在windows系统用odbc连接

    当连接的数据出现失败时,出现数据库别名仍然存在,但还是要用这个别名重新建立连接 在windows客户端,用输入db2cmd输入c:\Users\yexuxia>db2 list db direc ...

  10. .bat批处理命令的介绍

    HUC = = D组 http://www.cnhonkerarmy.com/ 63707869 =====================================开始============ ...