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. PHP求时间间隔 n天、周、月、年后的时间

    <?php date_default_timezone_set('PRC'); // 设置时区 $date1 = strtotime('2015-01-01'); //把日期转换成时间戳 $da ...

  2. Pyqt 打包资源文件

    用打包工具将做好的Pyqt程序打包成exe后发现引用的资源图片都显示不了? 是否遇到了和我一样的问题呢.google之后找到了方法,一种方法是在程序中引用外部资源,另外一种方法是将资源文件转换为py文 ...

  3. 【翻译十一】java-原子性操作

    Atomic Access In programming, an atomic action is one that effectively happens all at once. An atomi ...

  4. 攻城狮在路上(贰) Spring(一)--- 软件环境、参考书目等一览表

    一.软件环境: 二.参考书目: <Spring 3.X 企业应用开发实战> 陈雄华.林开雄著 电子工业出版社出版 三.其他说明: spring 源码地址:https://github.co ...

  5. wp8 入门到精通 测量代码执行时间

    Stopwatch time = new Stopwatch(); byte[] target = new byte[size]; for (int j = 0; j < size; j++) ...

  6. jQuery实现长按按钮触发事件的方法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. 利用IdentityServer3在ASP.NET 5和Angular中实现OAuth2 Implicit Flow

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:之前介绍过的IdentityServer3虽然是基于Katana开发的,不过同样可以托 ...

  8. Input对象的type类型

    Input表示Form表单中的一种输入对象,其又随Type类型的不同而分文本输入框,密码输入框,单选/复选框,提交/重置按钮等,下面一一介绍. 1,type=text        输入类型是text ...

  9. loadrunner生成随机身份证和银行卡号

    生成银行卡号码: Action() { char card[19] = {'6','2','2','7','0','0','0','0','0','0','0','0','0','0','0','0' ...

  10. c#基础系列(转)

    转:http://www.cnblogs.com/landeanfen/p/4953025.html C#基础系列——一场风花雪月的邂逅:接口和抽象类 前言:最近一个认识的朋友准备转行做编程,看他自己 ...