题目连接:Codeforces 387B George and Round
题目大意:有n个任务,给出n个任务的复杂度,序列a。然后可以事做好一些复杂度的准备,m个序列b,这要复杂度b[i] >= a[j],就可以省去一次工作量,问说还要解决几个问题。
解题思路:贪心,尽量用小的b解决小的a,然后a从小的开始抵消。
#include <stdio.h>
#include <string.h>
const int N = 1000005;
const int INF = 0x3f3f3f3f;
int n, m, a[N];
void init() {
int k;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
}
int solve() {
int ans = 0, p = 0, k;
for (int i = 0; i < m; i++) {
scanf("%d", &k);
if (k >= a[p] && p < n) {
p++; ans++;
}
}
return ans;
}
int main () {
init();
printf("%d\n", n - solve());
return 0;
}
分享到:
相关推荐
Codeforces 1105B - Zuhair and Strings 测试点37个(全)
Codeforces - 1107B. Digital root & 1107C. Brutality(规律 & 贪心)Codeforces - 1107B.
Codeforces global round 10 codes
Codeforces round 678 division 2 codes
暴枚最长桌脚的长度$l$,然后长度比$l$长的桌脚全部都要砍掉长度比$l$短的桌脚选择代价前$k$小的砍掉用线段树维护;示例程序 :typedef long l
Codeforces Round #723 (Div. 2).md
Codeforces round 678 D2_Codeforces_源码
Codeforces - 1131C. Birthday(贪心)题目链接题目给你n和n个数,要你重新排列n个数,使得这些数的相邻差值中最大的那个值最小。stat
Educational Codeforces Round 157D. XOR Construction
Codeforces 题库 101-200 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
Codeforces 题库 001-100 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
E. Cyclic Components 题目链接-E. Cyclic Components 题目大意 给你nnn个点和mmm条边,求所构成图中单圈环的个数 ...并查集并查集并查集 很明显单圈环每个点的度都为222,所以我们可以用数组cnt[]记录每个点的度,...
codeforces编程网站预测分数插件
目录传送门题意:思路:代码: 传送门 题意: 思路: 排个序,然后从最大的开始判断是否合适即可 代码: #include #include #include #include #include #include #include ...#define SZ(x) (
使用于Google Chrome的Codeforces Enhancer 1.1.2插件安装包。 版本:codeforces enhancer 1.1.2 使用浏览器:Google Chrome
Codeforces 185A - Plant 全测试点49个
codeforces 19 E Fairy 一道比较难的题目的解题报告 推荐阅读
题目大意:给出 n 个数字组成的序列,现在可以对数列进行多次操作,每次操作可以选择其中一段连续的数列,用其平均数替换原位置,换句话说,若原连续数列为 1 2 3,则可以替换为 2 2 2,问如何操作可以使得最后答案...
Some of the Codeforces problems codes
今天CF被D恶心到了,写个题解重新整理下思路,(20开始想,25写完暴力代码,1.30才过,优化后的。。 核心思路就是在暴力的基础上进行组合数等差加速。 C(n-2,i-1)*C(j-1,n-2)*(i-1) __ j: n-1 -> m ...