C好像就是个模拟。D 是个编码复杂度大的,可是好像也就是枚举三角形,我这会儿准备区域赛,尽量找点思维难度大的,所以昨晚A B 还是去做区域赛题吧.....

B 也有点意思 贪心

题意:交换相邻两个位的数。然后最多换k次,求最大数

解法,找<=k范围内的最大数。与之交换。右移一位。继续找,直到k用完

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std; #define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const double pi = acos(-1.0);
const int INF = 100000000; int num[65];
ll a;
int k; int change()
{
ll t=a;
int f=0;
while(t)
{
num[f++]=t%10;
t/=10;
}
return f;
} void print()
{
int id=64;
while(!num[id])--id;
//printf("%d",num[id]);
for(int i=id;i>=0;i--)
printf("%d",num[i]);
putchar('\n');
} int main()
{ while(~scanf("%I64d%d",&a,&k))
{
CL(num,0);
int wei=change();
wei--;
for(int i=wei;i>=0;i--)
{
int maxpos=i,mx=num[i],cnt=k;
for(int j=i-1;j>=0 && cnt>=1;j--)//
{
cnt--;
if(num[j] > mx){mx=num[j];maxpos=j;}
}
//k-=i-maxpos;
//cout << "***************" << endl;
//cout << "mx=" << mx << "pos=" << maxpos << endl;
//print();
///////
// printf("i=%d k=%d\n",i,k);
//for(int j=i-1;j>=maxpos && k>=1;j--)
//swap(num[j],num[j+1]),k--;
for(int j=maxpos;j<=i-1&&k>=1;j++)
swap(num[j],num[j+1]),k--;
if(!k)break;
}
print();
}
return 0;
}

A  纯模拟暴力

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std; #define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const double pi = acos(-1.0);
const int INF = 100000000; const int MAXN= 200;
int num[MAXN]; int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
for(int i=0;i<n;i++)
scanf("%d",&num[i]);
int ans=0,d=0;
for(int i=0;i<n;i++)
{
if(m-d>=num[i])
{
d+=num[i];
}
else
{
ans++;
d=num[i];
}
}
printf("%d\n",ans+1);
}
return 0;
}

Codeforces Round #249 (Div. 2) A B的更多相关文章

  1. 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram

    题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...

  2. Codeforces Round #249 (Div. 2) C题,模拟画图 ----未解决!

    http://codeforces.com/contest/435/problem/C

  3. Codeforces Round #249 (Div. 2)B(贪心法)

    B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. Codeforces Round #249 (Div. 2) A题

    链接:http://codeforces.com/contest/435/problem/A   A. Queue on Bus Stop time limit per test 1 second m ...

  5. Codeforces Round #249 (Div. 2) D. Special Grid 枚举

    题目链接: http://codeforces.com/contest/435/problem/D D. Special Grid time limit per test:4 secondsmemor ...

  6. Codeforces Round #249 (Div. 2) 总结

    D.E还是很难的.....C不想多说什么... A:提意:给出每一组人的个数,以及一次车载容量,求出最少需要多少次才能载走所有的人. water: http://codeforces.com/cont ...

  7. Codeforces Round #249 (Div. 2) (模拟)

    C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  8. Codeforces Round #249 (Div. 2) C. Cardiogram

    C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  9. Codeforces Round #249 (Div. 2) A. Black Square

    水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; ...

  10. Codeforces Round #249 (Div. 2) B. Pasha Maximizes

    看到题目的时候,以为类似插入排序,比较第i个元素和第i-1个元素, 如果第i个元素比第i-1个元素小,则不交换 如果第i个元素比第i-1个元素大,则交换第i个元素和第i-1个元素 继续比较第i-1个元 ...

随机推荐

  1. C-最长回文子串(1)

    最长回文子串,就是在字符串中找到最长的对称的子串. s是一个字符串. int max = 0; for(i = 0;i<m;i++) for(j = i;j<m;j++) if(s[i.. ...

  2. Windows Phone 8初学者开发—第20部分:录制Wav音频文件

    原文 Windows Phone 8初学者开发—第20部分:录制Wav音频文件 原文地址:http://channel9.msdn.com/Series/Windows-Phone-8-Develop ...

  3. maven常见问题汇总

    package阶段得到的是build目录下编译后的类包(jar),install是把这个包和一些maven的元信息(比如pom.xml)复制到本地仓库,assembly一般是把build结果和一些资源 ...

  4. img src某个php文件输出图片(回复更改图片readfile读取图片等)

    在论坛我们经常看到一回复图片就更改等,这功能是怎么实现的呢,其实更验证码道理相同. 新建文件 randimage.php 加入以下代码: <?php $dir='../../images/'; ...

  5. uva 10313 Pay the Price(完全背包)

    题目连接:10313 - Pay the Price 题目大意:有0~300这300种价值的金额. 现在可能给出参数: 1个:n, 输出可以组成价值n的方式的个数. 2个:n, a输出用个数小于a的价 ...

  6. Myeclipse 设定文件的默认打开方式

    Myeclipse 设定文件的默认打开方式.今天下载了一个properties的中文插件,希望.property的文件能默认以这个程序打卡.说一下设置方法. Window -> Preferen ...

  7. 【Cocos2d-x游戏引擎开发笔记(25)】XML解析

    原创文章,转载请注明出处:http://blog.csdn.net/zhy_cheng/article/details/9128819 XML是一种非常重要的文件格式,由于C++对XML的支持非常完善 ...

  8. c语言,变长数组

    下面这个结构体,可以在malloc的时候指定数据data的长度,这样的形式就是变长数组:typedef struct{ int data_len; char data[0];//或char data[ ...

  9. FastDFS的学习与使用(大量帖子)

    http://www.oschina.net/p/fastdfs http://bbs.chinaunix.net/forum-240-1.html

  10. ctfmon.exe开机无法自己主动启动

    打开命令提示符(開始菜单--执行--输入:cmd),输入下面命令(复制粘贴就可以): reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Ru ...