跳过正文
  1. Posts/

best coder #56 div 2 A Clarke and minecraft(贪心)

·1 分钟

贪心..尽量把一样的材料放在一起... 然后写蠢了..妈蛋... 详情见代码

 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 479D. Long Jumps

·2 分钟
http://codeforces.com/problemset/problem/479/D 题意是说有一把尺子,本身有一些刻度,然后需要测量x和y,问最少需要添加多少个刻度,如果需要,这些刻度分别添加在什么位置。

codeforces 525 B. Pasha and String

·1 分钟
http://codeforces.com/problemset/problem/525/B 1题意是说一个字符串,进行m次颠倒变换(从a[i]位置到a[l-i+1]位置),问得到的字符串。容易发现,对于越在里边(对称,也就是越靠近中间位置)的字符,调换的次数越多。我们可以把a[i]从小到大排序。然后经过分析发现,把两个相邻的a[i]分为一组,做处理,如果m为奇数,最后还剩下a[m]没有被分组,要单独处理a[m]细节上要注意st数组是从st[0]开始的...好吧的确不方便,适牛也说我了。。数组下标以后还是从0开始吧。。。主要是受高中OI用的pascal的影响。。。那个数组下标随便啊。代码: 2 3 4 5 6 /* *********************************************** 7 Author :111qqz 8 Created Time :2016年02月22日 星期一 23时39分51秒 9 File Name :code/cf/problem/525B.cpp 10 ************************************************ */ 11 12 #include <iostream> 13 #include <algorithm> 14 #include <cstring> 15 #include <cmath> 16 #include <cstdio> 17 18 using namespace std; 19 20 int m,k,len; 21 const int N=2E5+7; 22 int a[N]; 23 char st[N]; 24 25 int main() 26 { 27 cin>>st; 28 scanf("%d",&m); 29 for ( int i = 1 ; i <= m ; i++ ) 30 scanf("%d",&a[i]); 31 sort(a+1,a+m+1); 32 k = 1; 33 len = strlen(st); 34 while (k<=m) 35 { 36 for ( int j = a[k] ; j <= a[k+1]-1 ; j++) 37 swap(st[j-1],st[len-j]); 38 k = k + 2; 39 } 40 if ( m %2==1 ) 41 for ( int i = a[m]; i <= len/2 ; i++ ) 42 swap(st[i-1],st[len-i]); 43 cout<<st<<endl; 44 return 0; 45 }

codeforces 482 A. Diverse Permutation(构造)

·1 分钟
C - C **Time Limit:**1000MS **Memory Limit:**262144KB 64bit IO Format:%I64d & %I64u Submit Status Description Permutation_p_ is an ordered set of integers _p_1, p_2, …, p__n, consisting of n distinct positive integers not larger than n. We’ll denote as_n the length of permutation _p_1, _p_2, …, p__n.

codeforces 47 C. Exams

·1 分钟
http://codeforces.com/problemset/problem/479/C 1/************************************************ 2Author :111qqz 3Created Time :2016年02月22日 星期一 23时31分10秒 4File Name :code/cf/problem/479C.cpp 5************************************************ */ 6 7#include <iostream> 8#include <algorithm> 9#include <cstring> 10#include <cstdio> 11 12#include <cmath> 13 14using namespace std; 15int n,ans; 16const int N=1E4+5; 17int a[N],b[N]; 18 19struct Q 20{int a,b; 21}q[N]; 22 23bool cmp(Q x, Q y) 24{ 25 if ( x.a<y.a) return true; 26 if ( x.a==y.a &&x.b<y.b ) return true; 27 return false; 28} 29 30int main() 31{ 32 scanf("%d",&n); 33 for ( int i = 1 ; i <= n ; i++ ) 34 scanf("%d %d",&q[i].a,&q[i].b); 35 sort(q+1,q+n+1,cmp); 36 37 ans=q[1].b; 38 for ( int i = 2 ; i <= n; i++ ) 39 { 40 if ( q[i].b>=ans ) 41 ans = q[i].b; 42 else ans = q[i].a; 43 } 44 printf("%d\n",ans); 45 return 0; 46}