Codeforces Beta Round #4 (Div. 2 Only)
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)的更多相关文章
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
- Codeforces Beta Round #72 (Div. 2 Only)
Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...
- Codeforces Beta Round #70 (Div. 2)
Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...
随机推荐
- Linux 标准目录结构
初学Linux,首先需要弄清Linux 标准目录结构 / root --- 启动Linux时使用的一些核心文件.如操作系统内核.引导程序Grub等. home --- 存储普通用户的个人文件 ftp ...
- JavaScript 火花效果
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- 【mysql中myisam和innodb的区别】
单击进入源网页 要点摘要: 1.查看mysql存储引擎的状态mysql> show engines; 2.查看mysql默认的存储引擎mysql> show variables like ...
- a个人经验总结2
金额 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8& ...
- phpcms v9 常用调用标签(全)
本文介绍phpcms v9中模板标签使用说明. {template ) {==} {/,,)} loop是data的时候用{thumb($v[thumb],,)} 分页标签------{$ ...
- WebRTC代码走读(十):rtp_rtcp模块分析,webrtcrtp_rtcp
转自:http://www.bkjia.com/Androidjc/1020017.html 1. 对外提供的主要流程接口 收包的调用接口RtpReceiverImpl::Incoming ...
- loj 1037(状压dp)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=25914 思路:dp[state]表示当前状态下要消耗的最小的sho ...
- PowerDesigner 16.5
PowerDesigner165_破解文件.rar 链接:http://pan.baidu.com/s/1hqEDUCG 636KB PowerDesigner165_Evaluation ...
- ubuntu安装shadowshocks-qt5
sudo add-apt-repository ppa:hzwhuang/ss-qt5 sudo apt-get update sudo apt-get install shadowsocks-qt5 ...
- mysql root用户 远程登录其它机器,看不到数据库
在102上访问101上的数据库里,show databases;看不到里面的库, 需要在101上授权就可以了 GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.16 ...