http://codeforces.com/contest/479/problem/A

枚举情况

 #include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int a,b,c;
while(~scanf("%d%d%d",&a,&b,&c)){
int ans=;
ans=max(ans,a+b+c);
ans=max(ans,a*b*c);
ans=max(ans,a*b+c);
ans=max(ans,a+b*c);
ans=max(ans,(a+b)*c);
ans=max(ans,a*(b+c));
printf("%d\n",ans);
}
return ;
}

http://codeforces.com/contest/479/problem/B

暴力,每次拿一个,然后排序。

 #include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int inf=0x3f3f3f3f;
struct G{
int val,id;
friend bool operator <(const G &a,const G &b){
return a.val<b.val;
}
}g[];
struct A{
int x,y;
}now;
vector<A> ans;
int main(){
int n,k;
while(~scanf("%d%d",&n,&k)){
int big=,sma=inf,cha;
for(int i=;i<n;i++){
scanf("%d",&g[i].val);
g[i].id=i+;
big=max(big,g[i].val);
sma=min(sma,g[i].val);
}
cha=big-sma;
ans.clear();
while(k--&&cha){
sort(g,g+n);
g[].val++;
g[n-].val--;
big=;
sma=inf;
for(int i=;i<n;i++){
big=max(big,g[i].val);
sma=min(sma,g[i].val);
}
if(big-sma>cha) break;
cha=big-sma;
now.x=g[n-].id;
now.y=g[].id;
ans.push_back(now);
}
printf("%d %d\n",cha,ans.size());
int len=ans.size();
for(int i=;i<len;i++){
printf("%d %d\n",ans[i].x,ans[i].y);
}
}
return ;
}

c

贪心

 #include<cstdio>
#include<algorithm>
using namespace std;
const int M=;
struct G{
int a,b;
friend bool operator <(const G &a,const G &b){
return a.a<b.a;
}
}g[M];
int main(){
int n;
while(~scanf("%d",&n)){
for(int i=;i<n;i++){
scanf("%d%d",&g[i].a,&g[i].b);
}
sort(g,g+n);
int now=;
for(int i=;i<n;){
int s=i,t;
int big=;
int sma=0x3f3f3f3f;
for(int j=i;j<n;j++){
if(g[i].a==g[j].a){
t=j;
big=max(big,g[j].b);
sma=min(sma,g[j].b);
}
else{
break;
}
}
if(big<g[i].a&&sma>=now){
now=big;
}
else{
now=g[i].a;
}
i=t+;
}
printf("%d\n",now);
}
return ;
}

d

map 判断是否存在

 #include<cstdio>
#include<map>
using namespace std;
const int M=1e5+;
int a[M];
int l;
map<int,bool> mp;
bool has(int x,int y) {
if(mp[x+y]||mp[x-y]) return true;
return false;
}
bool in(int x) {
if(x>=&&x<=l) return true;
return false;
}
int main() {
int n,x,y;
while(~scanf("%d%d%d%d",&n,&l,&x,&y)) {
mp.clear();
for(int i=; i<n; i++) {
scanf("%d",&a[i]);
mp[a[i]]=true;
}
bool fx=false,fy=false;
for(int i=; i<n; i++) {
if(has(a[i],x)) {
fx=true;
}
if(has(a[i],y)) {
fy=true;
}
}
if(fx&&fy) {
puts("");
continue;
}
if(!fx&&fy) {
puts("");
printf("%d\n",x);
continue;
}
if(fx&&!fy) {
puts("");
printf("%d\n",y);
continue;
}
int ans=-;
for(int i=; i<n; i++) {
if(in(a[i]-x)&&has(a[i]-x,y)) {
ans=a[i]-x;
break;
}
if(in(a[i]+x)&&has(a[i]+x,y)) {
ans=a[i]+x;
break;
}
if(in(a[i]-y)&&has(a[i]-y,x)) {
ans=a[i]-y;
break;
}
if(in(a[i]+y)&&has(a[i]+y,x)) {
ans=a[i]+y;
break;
}
}
if(ans!=-) {
puts("");
printf("%d\n",ans);
} else {
puts("");
printf("%d %d\n",x,y);
}
}
return ;
}

end

Codeforces Round #274 (Div. 2)的更多相关文章

  1. Codeforces Round #274 (Div. 1) C. Riding in a Lift 前缀和优化dp

    C. Riding in a Lift Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/pr ...

  2. Codeforces Round #274 (Div. 1) B. Long Jumps 数学

    B. Long Jumps Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/ ...

  3. Codeforces Round #274 (Div. 1) A. Exams 贪心

    A. Exams Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/A Des ...

  4. codeforces水题100道 第八题 Codeforces Round #274 (Div. 2) A. Expression (math)

    题目链接:http://www.codeforces.com/problemset/problem/479/A题意:给你三个数a,b,c,使用+,*,()使得表达式的值最大.C++代码: #inclu ...

  5. Codeforces Round #274 (Div. 2)-C. Exams

    http://codeforces.com/contest/479/problem/C C. Exams time limit per test 1 second memory limit per t ...

  6. Codeforces Round #274 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/479 这次自己又仅仅能做出4道题来. A题:Expression 水题. 枚举六种情况求最大值就可以. 代码例如以下: #inc ...

  7. Codeforces Round #274 Div.1 C Riding in a Lift --DP

    题意:给定n个楼层,初始在a层,b层不可停留,每次选一个楼层x,当|x-now| < |x-b| 且 x != now 时可达(now表示当前位置),此时记录下x到序列中,走k步,最后问有多少种 ...

  8. Codeforces Round #274 (Div. 2) E. Riding in a Lift(DP)

    Imagine that you are in a building that has exactly n floors. You can move between the floors in a l ...

  9. Codeforces Round #274 (Div. 2) --A Expression

    主题链接:Expression Expression time limit per test 1 second memory limit per test 256 megabytes input st ...

随机推荐

  1. android学习视频分享

    最近整理了大量的安卓开发学习资料,有书籍有视频有代码,老罗的第一季有点老了, 这里就给大家分享下老罗的第二季的视频教程吧,还有源码,初级到高级程序猿都有用. 下载地址:http://51pansou. ...

  2. 怎样用foreach去修改数组之中的数据

    $table_exchange=array(1,2,3,4,5,6,7,8); foreach ($table_exchange as $b=>$c){ $table_exchange[$b]= ...

  3. Apache 多端口多站点配置实例

    分享下Apache多端口多站点的配置方法,配置apache服务器的朋友参考下. 配置httpd.conf 监听多个端口 复制代码代码如下: # Listen: Allows you to bind A ...

  4. Flask Web Development —— Web表单(上)

    Flask-WTF扩展使得处理web表单能获得更愉快的体验.该扩展是一个封装了与框架无关的WTForms包的Flask集成. Flask-WTF和它的依赖集可以通过pip来安装: (venv) $ p ...

  5. Python超简单的HTTP服务器

    Python超简单的HTTP服务器 安装了python就可以 python -m SimpleHTTPServer 执行这一个命令即可实现一个HTTP服务器,将当前目录设为HTTP服务目录,可以通过h ...

  6. wpf 动画 2个窗体切换

    <Window x:Class="翻转.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xam ...

  7. 微软CRM解决医药企业串货之痛

    没有准确.及时的流向数据统计和分析,医药企业营销部门就无法有效管理串货泛滥问题,串货会造成渠道无利可赚,挫伤渠道的积极性,产品无人愿意卖,最终伤害的还是医药企业. 医药企业营销发展的不同阶段对串货的态 ...

  8. Should .close() be put in finally block or not?

    The following are 3 different ways to close a output writer. The first one puts close() method in tr ...

  9. 三种嵌入式web服务器(Boa / lighttpd / shttpd)的 linux移植笔记

    一:移植Boa(web服务器)到嵌入式Linux系统 一.Boa程序的移植 1.下载Boa源码    下载地址: http://www.boa.org/    目前最新发行版本: 0.94.13   ...

  10. IIS 404.17 错误解决方案

    操作方法:在管理员身份打开命令行,运行以下命令: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -i