打得最烂一场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. Row_Number实现分页

    1:首先是 select ROW_NUMBER() over(order by id asc) as 'rowNumber', * from table1 生成带序号的集合 2:再查询该集合的 第 1 ...

  2. 【转】哦,mysql 的其它发行版本Percona, mariadb

    原文:http://geek.csdn.net/news/detail/130146 2016年11月25日,沃趣科技"智慧应用 数据先行"2016产品发布会暨新三板挂牌庆祝会在杭 ...

  3. EL(表达式语言)

    EL(Expression Language):目的是为了简化Jsp页面的语言,使页面看起来更加简洁 基本的语法特点 以“${"开头,以”}“结束 一 与低版本的环境兼容----禁用EL ( ...

  4. The Rings Akhaten

    在其他的平行宇宙中存在着一个古老的星系--Akhaten,星系中有七个世界,上面生活着Panbabylonian.Lucanian等物种,不过外界也常常把他们统称为Akhet,因为这七个世界环绕着同一 ...

  5. cfedu/A/求和

    题目连接 思路: 用数组直接标记2^n,n属于(0~~31);用LL或者INT都可以,不会爆.但是ans要用LL. #include <set> #include <map> ...

  6. contentHorizontalAlignment 属性浅析

    转载自:http://blog.csdn.net/s0228g0228/article/details/46832285 最近在iOS 7以上总是碰到导航条上左右按钮距离边距太大的问题 为了解决这个这 ...

  7. nagios安装全过程

    Nagios是一个用来监控主机.服务和网络的开放源码软件,可以在发生故障时发送报警短信和邮件,只要Nagios监控的对象发生故障,系统就会自动发送短信到手机上.所以应用十分广泛. Nagios is  ...

  8. lucene-SpanQuery跨度查询基础

    1.跨度查询SpanQuery5个子类 SpanQuery类型                            描述 SpanTermQuery                和其他跨度查询结合 ...

  9. HDU1518:Square(DFS)

    Square Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submi ...

  10. AngularJS继续中

    <html ng-app>//全局中引用对应于PhoneListCtrl 模板 <head> <script src="js/angular.js"& ...