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. Android的两种事件处理机制

    UI编程通常都会伴随事件处理,Android也不例外,它提供了两种方式的事件处理:基于回调的事件处理和基于监听器的事件处理. 对于基于监听器的事件处理而言,主要就是为Android界面组件绑定特定的事 ...

  2. 【翻译三】java-并发之线程对象和实现

    Thread Objects Each thread is associated with an instance of the class Thread. There are two basic s ...

  3. 【JAVA单例模式详解】

    设计模式是一种思想,适合于任何一门面向对象的语言.共有23种设计模式. 单例设计模式所解决的问题就是:保证类的对象在内存中唯一. 举例: A.B类都想要操作配置文件信息Config.java,所以在方 ...

  4. html5 三角形

    html5 三角形 <!DOCTYPE html> <html> <head lang="en"> <meta charset=" ...

  5. Thinkphp 解决写入配置文件的方法

    在/Application/Common/Common创建function.php,然后添加以下代码: <?php /** * [writeArr 写入配置文件方法] * @param [typ ...

  6. [J2EE] 在Web如何取得相关路径

    来自网络,自己整整一下: request.getRealPath("url"); // 虚拟目录映射为实际目录,不建议使用,使用ServletContext.getRealPath ...

  7. 函数fgets和fputs、fread和fwrite、fscanf和fprintf用法小结 (转)

    函数fgets和fputs.fread和fwrite.fscanf和fprintf用法小结 字符串读写函数fgets和fputs 一.读字符串函数fgets函数的功能是从指定的文件中读一个字符串到字符 ...

  8. [Liferay6.2]Connect to ajax.googleapis.com …… timed out

    启动liferay 6.2 tomcat之后,后台会报一大段的异常信息,主要异常信息如下: -- :: org.apache.shindig.gadgets.http.BasicHttpFetcher ...

  9. wpf textblock 会覆盖 button里面字体样式的解决方法 还有button的style覆盖。。datepicker里面的按钮的style

    .(button使用contont写的时候) 当.button使用 <button.content><textBlock/></button.content>依然会 ...

  10. AndroidManifest.xml权限大全

    本文转  https://my.oschina.net/duwaiweb/blog/75935 问登记属性 android.permission.ACCESS_CHECKIN_PROPERTIES , ...