SRM149 - SRM150(少SRM150-DIV1-LV3)
2013-08-15 01:31
239 查看
SRM 149
DIV2 1000pt
题意:
对于n个人,第i人有pi的钱。将他们分成不超过四个组,每组统一交费x,对每个人,若他拥有的钱超过x则交费,否则不交费。问最多能使这些人交多少钱。
1<= n <= 50,0 <= pi <= 1000。
tag:greedy,think
解法:枚举所有分组情况,每组交费x为该组中最小的pi。如果分组不足四组,补足四组,每组均含一个人钱数为0的人。
Ps:感觉自己的代码写得比题解舒服.....
View Code
DIV2 1000pt
题意:
对于n个人,第i人有pi的钱。将他们分成不超过四个组,每组统一交费x,对每个人,若他拥有的钱超过x则交费,否则不交费。问最多能使这些人交多少钱。
1<= n <= 50,0 <= pi <= 1000。
tag:greedy,think
解法:枚举所有分组情况,每组交费x为该组中最小的pi。如果分组不足四组,补足四组,每组均含一个人钱数为0的人。
Ps:感觉自己的代码写得比题解舒服.....
#line 10 "StripePainter.cpp" #include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <iostream> #include <sstream> #include <set> #include <queue> #include <fstream> #include <numeric> #include <iomanip> #include <bitset> #include <list> #include <stdexcept> #include <functional> #include <string> #include <utility> #include <map> #include <ctime> #include <stack> using namespace std; #define CLR(x) memset(x, 0, sizeof(x)) #define PB push_back #define SZ(v) ((int)(v).size()) #define out(x) cout<<#x<<":"<<(x)<<endl #define tst(a) cout<<#a<<endl #define CINBEQUICKER std::ios::sync_with_stdio(false) typedef vector<int> VI; typedef vector<string> VS; typedef vector<double> VD; typedef long long int64; const double eps = 1e-8; const double PI = atan(1.0)*4; const int maxint = 2139062143; inline int MyMod( int a , int b ) {a = a % b;if (a < 0) a += b; return a;} string s; int m[55][55][100]; int ask(int l, int n, char c) { int& a = m[l] [(int)c]; if (!n) return 0; if (a != -1) return a; a = maxint; if (c == s[l]){ a = ask (l+1, n-1, c); return a; } for (int i = 1; i < n; ++ i) for (int j = 'A'; j <= 'Z'; ++ j) a = min (a, 1 + ask(l, i, s[l]) + ask(l+i, n-i, c)); a = min (a, 1 + ask(l, n, s[l])); return a; } class StripePainter { public: int minStrokes(string stripes){ s.clear(); s = stripes; memset (m, -1, sizeof (m)); int size = SZ (s); for (int i = 0; i < size; ++ i) for (int j = 0; j + i <= size; ++ j) for (int k = 'A'-1; k <= 'Z'; ++ k) m[i][j][k] = 1 + ask(i, j, (char)k); return (m[0][size][(int)s[0]]); } };
View Code
相关文章推荐
- SRM149_DIV2
- TopCoder 250 points 14-SRM 150 DIV 2 86.25/250 34.50%
- TopCoder算法竞赛题5:SRM 149 DIV 2, 250-point
- TopCoder算法竞赛题6:SRM 150 DIV 2, 250-point
- SRM150_DIV2
- TopCoder 250 points 11-SRM 149 DIV 1 86.62/250 34.65%
- TopCoder 250 points 12-SRM 149 DIV 2 103.92/250 41.57%
- TopCoder 250 points 13-SRM 150 DIV 1 82.63/250 33.05%
- topcoder srm 531 div2 600pt
- SRM 219 Div II Level One: WaiterTipping,小心约分
- Topcoder SRM 584 DIV2 解题报告
- SRM 670 div2 A B C div1 A(贪心,子问题合并)
- [LP对偶费用流] SRM 676 div1 Farmville
- SRM 622 div1
- SRM536-div1-2-RollingDiceDivOne
- SRM 578 Div II Level Two: GooseInZooDivTwo, DFS
- srm537 div1
- srm538 div1
- [矩阵树定理 容斥 meet in middle] Topcoder SRM 551 DIV1 Hard. SweetFruits
- [TopCoder] SRM 587 DIV 2, 250p, 500p, 1000p, Solution