Educational Codeforces Round 47 (Rated for Div. 2) :A. Game Shopping
题目链接:http://codeforces.com/contest/1009/problem/A
解题心得:
- 题意就是给你两个数列c,a,你需要从c中选择一个子串从a头开始匹配,要求子串中的连续的前k个数都要比对应的a中数小,问k最大是多少。
- 大比赛的时候自己在枚举题意,搞了好久心态差点崩了。
#include <bits/stdc++.h>
using namespace std;
const int maxn = ; int n,m;
int a[maxn],c[maxn];
void init() {
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
scanf("%d",&c[i]);
for(int i=;i<=m;i++)
scanf("%d",&a[i]);
} void solve() {
int ans = ;
int last = ;
for(int i=;i<=m;i++) {//暴力枚举匹配
for(int j=last;j<=n;j++) {
if(a[i] >= c[j]) {
ans++;
last = j+;
break;
}
else{
last = j+;
}
}
}
printf("%d",ans);
}
int main() {
init();
solve();
return ;
}
Educational Codeforces Round 47 (Rated for Div. 2) :A. Game Shopping的更多相关文章
- Educational Codeforces Round 47 (Rated for Div. 2) :E. Intercity Travelling
题目链接:http://codeforces.com/contest/1009/problem/E 解题心得: 一个比较简单的组合数学,还需要找一些规律,自己把方向想得差不多了但是硬是找不到规律,还是 ...
- Educational Codeforces Round 47 (Rated for Div. 2) :D. Relatively Prime Graph
题目链接:http://codeforces.com/contest/1009/problem/D 解题心得: 题意就是给你n个点编号1-n,要你建立m条无向边在两个互质的点之间,最后所有点形成一个连 ...
- Educational Codeforces Round 47 (Rated for Div. 2) :C. Annoying Present(等差求和)
题目链接:http://codeforces.com/contest/1009/problem/C 解题心得: 题意就是一个初始全为0长度为n的数列,m此操作,每次给你两个数x.d,你需要在数列中选一 ...
- Educational Codeforces Round 47 (Rated for Div. 2) :B. Minimum Ternary String
题目链接:http://codeforces.com/contest/1009/problem/B 解题心得: 题意就是给你一个只包含012三个字符的字符串,位置并且逻辑相邻的字符可以相互交换位置,就 ...
- Educational Codeforces Round 55 (Rated for Div. 2):E. Increasing Frequency
E. Increasing Frequency 题目链接:https://codeforces.com/contest/1082/problem/E 题意: 给出n个数以及一个c,现在可以对一个区间上 ...
- Educational Codeforces Round 55 (Rated for Div. 2):D. Maximum Diameter Graph
D. Maximum Diameter Graph 题目链接:https://codeforces.com/contest/1082/problem/D 题意: 给出n个点的最大入度数,要求添加边构成 ...
- Educational Codeforces Round 55 (Rated for Div. 2):C. Multi-Subject Competition
C. Multi-Subject Competition 题目链接:https://codeforces.com/contest/1082/problem/C 题意: 给出n个信息,每个信息包含专业编 ...
- Educational Codeforces Round 47 (Rated for Div. 2) 题解
题目链接:http://codeforces.com/contest/1009 A. Game Shopping 题目: 题意:有n件物品,你又m个钱包,每件物品的价格为ai,每个钱包里的前为bi.你 ...
- Educational Codeforces Round 47 (Rated for Div. 2)E.Intercity Travelling
题目链接 大意:一段旅途长度N,中间可能存在N-1个休息站,连续走k长度时,疲劳值为a1+a2+...+aka_1+a_2+...+a_ka1+a2+...+ak,休息后a1a_1a1开始计, ...
随机推荐
- mysql 统计连续天数
以下为例子数据 图1 图1 首先根据要求取出BeforeMeal要在7.0以下 并且 bingAfterMeal要在11.1以下 select AccountId,CreateTime from Di ...
- 初次撸Python,踩平些小坑~
[转义字符] os.path.isdir(targetPath)总是报错,以为字符串不行而是要转成file类型,尝试了很多方法还是没解决,最后发现,windows下的路径中字符串中需要转义(例子在网上 ...
- Struts2学习-拦截器2
1.做一个登陆页面(loginView.jsp,才用Action来访问),2.登陆成功后,可以跳转到系统的首页(index.jsp),3.首页有一个链接(testOtherAction访问其它的功能模 ...
- gridview导出exe处理时遇到RegisterForEventValidation can only be called during Render();错误
如题,今天在利用GridView作execl导出时,遇到RegisterForEventValidation can only be called during Render();问题.根据网上找到的 ...
- 解决SQLite打开已有路径下的db问题
最近遇到的需要加载已有路径下(sd card下)db的问题,找了一下资料,以下是解决的方法,仅供参考(转载自eoe): SQLiteOpenHelper 是Android框架为我们提供的一个非常好的数 ...
- std::string::find_last_not_of
public member function <string> std::string::find_last_not_of C++98 C++11 string (1) size_t fi ...
- Sql Server中一次更新多列数据
UPATE yourTableName SET column1 = xx, column2 = yy , column3 = zz WHERE yourCondition 举个例子,比如有这样一张表: ...
- (转)python with as的用法
源地址https://www.cnblogs.com/DswCnblog/p/6126588.html With语句是什么? 有一些任务,可能事先需要设置,事后做清理工作.对于这种场景,Python的 ...
- [BJWC2008]秦腾与教学评估
嘟嘟嘟 二分好题. 怎么二分呢?反正我是没想出来. 看了题解. 因为只有一个为奇数的点,所以对于一个位置x,求出区间[0, x]的教总和,如果为奇数,说明x取大了:否则x取小了(妙啊). 虽然答案在i ...
- win10 安装YII2
YII2下载地址:http://www.yiichina.com/download 高级版本和基本版本的区别是: 基础版只有一个只有一个web应用,高级版则生成前后台.建议使用高级版,方便 Yii2框 ...