A题,水题,准1Y,第一次CE了。。CF里,CE没有罚时。。

B题,直接模拟。。

#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int minz[],maxz[],ans[];
int main()
{
int d,sum,i,temp;
scanf("%d%d",&d,&sum);
temp = ;
for(i = ; i < d; i ++)
{
scanf("%d%d",&minz[i],&maxz[i]);
ans[i] = minz[i];
temp += minz[i];
}
if(temp > sum)
printf("NO\n");
else
{
for(i = ; i < d; i ++)
{
if(temp == sum) break;
if(sum - temp > maxz[i]-minz[i])
{
ans[i] = maxz[i];
temp += maxz[i] - minz[i];
}
else
{
ans[i] += sum - temp;
temp = sum;
}
}
if(temp < sum)
printf("NO\n");
else
{
printf("YES\n");
for(i = ; i < d; i ++)
printf("%d ",ans[i]);
}
}
return ;
}

C题,1Y.不能再水。。

D题,无聊排序DP。2Y,我不能忍。。

#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
using namespace std;
struct node
{
int w,h,id;
}p[];
int flag[];
int n;
int cmp(node a,node b)
{
if(a.w == b.w)
return a.h > b.h;
else
return a.w > b.w;
}
int dp[];
void dfs(int x)
{
int i;
if(dp[x] == ) return ;
for(i = ;i < x;i ++)
{
if(p[i].w > p[x].w&&p[i].h > p[x].h&&dp[i]+ == dp[x])
{
printf("%d ",p[i].id);
dfs(i);
break;
}
}
}
int main()
{
int i,maxz,j;
scanf("%d",&n);
for(i = ;i <= n;i ++)
{
scanf("%d%d",&p[i].w,&p[i].h);
p[i].id = i;
}
sort(p,p+n+,cmp);
for(i = ;i <= n;i ++)
{
maxz = ;
for(j = ;j < i;j ++)
{
if(p[j].w > p[i].w&&p[j].h > p[i].h)
maxz = max(maxz,dp[j]);
}
dp[i] = maxz + ;
}
for(i = ;i <= n;i ++)
{
if(p[i].id == )
{
printf("%d\n",dp[i]-);
dfs(i);
break;
}
}
return ;
}

Codeforces Beta Round #4 (Div. 2 Only)的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  3. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  4. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  5. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  7. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  8. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  9. Codeforces Beta Round #72 (Div. 2 Only)

    Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...

  10. Codeforces Beta Round #70 (Div. 2)

    Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...

随机推荐

  1. Delphi面向对象---接口

    从Delphi3开始支持接口.接口定义了能够与一个对象进行交互操作的一组过程和函数.对一个接口进行定义包含两个方面的内容: 1)一方面是实现这个接口 2)另一方面是定义接口的客户 一个类能够实现多个接 ...

  2. 【转载】 python修饰符@

    @符号在python语言中具有特殊含义,用来作为修饰符使用, @修饰符有点像函数指针,python解释器发现执行的时候如果碰到@修饰的函数,首先就解析它,找到它对应的函数进行调用,并且会把@修饰下面一 ...

  3. Linux中带颜色输出的printf使用简介(\033)

    昨晚懒得FQ, 百度了一下linux中printf输出颜色的方法, 结果搜索结果质量让人倍感伤心. 越来越不想用bd了.还是Google一下吧, 手气真好, 第一个内容就很清楚明了! 我还是直接简单翻 ...

  4. linux下搭建属于自己的博客(WordPress安装)

    转自:http://www.cnblogs.com/xiaofengkang/archive/2011/11/16/2251608.html WordPress简介 WordPress 是一种使用 P ...

  5. PMP 第六章 项目时间管理

    定义活动 排列活动顺序 估算活动资源 估算活动持续时间 制定进度计划 控制进度计划 1.进度管理计划和进度计划的内容分别是什么,有什么区别? 进度计划:项目各活动计划完成日期的编排.    进度管理计 ...

  6. ASSM 的三级位图结构

    自动段空间管理(ASSM),它首次出现在Oracle920里(在920以前,段空间的管理方式叫做MSSM,它是由连接列表freelist来完成的,因为freelist存在串行的问题,因此容易引起段头的 ...

  7. 基于ZigBee的家居控制系统的设计与应用

    基于ZigBee的家居控制系统的设计与应用 PPT简介:http://pan.baidu.com/s/1i38PC6D 摘  要 智能家居是未来家居的发展方向,其利用先进的网络技术.计算机技术和无线通 ...

  8. while do while以及穷举和迭代

    今天的新内容1:while循环 格式: while() { } 初始状态要在循环外提前规定 状态改变要写在花括号里面 括号内是循环条件 for循环与while循环的对比: 2:do while 不管循 ...

  9. SQL多表查询案例

    表结构: emp表: dept表: salgrade表: (1)查出至少有一个员工的部门.显示部门编号.部门名称.部门位置.部门人数. SELECT z.*,d.dname,d.loc FROM de ...

  10. CodeForces 19D Points(线段树+map)

    开始想不通,后来看网上说是set,就有一个想法是对每个x建一个set...然后又想直接建立两重的set就好,最后发现不行,自己想多了...  题意是给你三种操作:add (x y) 平面添加(x y) ...