Note: This article is available in Chinese only. 本文暂无英文版本。
View original
zoj 3627 F - Treasure Hunt II(贪心)
Related
51nod_learn_greedy_活动安排2
有若干个活动,第i个开始时间和结束时间是[Si,fi),同一个教室安排的活动之间不能交叠,求要安排所有活动,最少需要几个教室?
1第一行一个正整数n (n <= 10000)代表活动的个数。 2第二行到第(n + 1)行包含n个开始时间和结束时间。 3开始时间严格小于结束时间,并且时间都是非负整数,小于1000000000 输出
一行包含一个整数表示最少教室的个数。 输入示例
best coder #56 div 2 A Clarke and minecraft(贪心)
贪心..尽量把一样的材料放在一起... 然后写蠢了..妈蛋... 详情见代码
代码实现 1/************************************************************************* 2 > File Name: code/bc/#56/1001.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年09月19日 星期六 18时55分49秒 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#include<cctype> 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define ms(a,x) memset(a,x,sizeof(a)) 25#define lr dying111qqz 26using namespace std; 27#define For(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef double DB; 30const int inf = 0x3f3f3f3f; 31const int N=5E2+7; 32int a[N],b[N]; 33int ans,cnt; 34int p[N]; 35int n; 36int main() 37{ 38 #ifndef ONLINE_JUDGE 39 freopen("in.txt","r",stdin); 40 #endif 41 int T; 42 cin>>T; 43 while (T--) 44 { 45 ans = 0; 46 cnt = 0; 47 ms(p,0); 48 scanf("%d",&n); 49 for ( int i = 0 ; i < n ; i++ ) 50 { 51 scanf("%d %d",&a[i],&b[i]); 52 p[a[i]]+=b[i]; 53 } 54 int kind = 0; 55 for ( int i = 1 ;i <= 500 ; i++) 56 { 57 if (p[i]!=0) 58 { 59 // cnt = cnt + (p[i]-1)/64 + 1; 60 cnt = cnt + (p[i]+63)/64; //这样写不知高到哪里去了. 61 p[i] = 0; 62 } 63 64 } 65 //ans = ans + (cnt-1)/36+1; 66 ans = (cnt+35)/36; //不知高到哪里去了... 67 printf("%d\n",ans); 68 69 70 } 71 72 73 #ifndef ONLINE_JUDGE 74 fclose(stdin); 75 #endif 76 return 0; 77}
codeforces 558c Amr and Chemistry (贪心)
·759 words·2 mins
http://codeforces.com/contest/558/problem/C
题目大意是说,给定N个数,可以对任意数进行任意次两种操作,×2,和/2(整除)
问最少操作多少次,可以让所有数相等。
嘛,前半个小时A掉了前两个提,d E貌似都是线段树。。并不会。。。就一直搞C。。。。
codeforces 479D. Long Jumps
http://codeforces.com/problemset/problem/479/D
题意是说有一把尺子,本身有一些刻度,然后需要测量x和y,问最少需要添加多少个刻度,如果需要,这些刻度分别添加在什么位置。
一开始没有看清题目,以为答案最多为4,但是发现,a[1]=0 a[n]=l这两个是确定的,所以答案最多为2,