水 A - Vasya the Hipster

  1. /************************************************
  2. * Author :Running_Time
  3. * Created Time :2015/9/28 星期一 16:58:13
  4. * File Name :A.cpp
  5. ************************************************/
  6.  
  7. #include <cstdio>
  8. #include <algorithm>
  9. #include <iostream>
  10. #include <sstream>
  11. #include <cstring>
  12. #include <cmath>
  13. #include <string>
  14. #include <vector>
  15. #include <queue>
  16. #include <deque>
  17. #include <stack>
  18. #include <list>
  19. #include <map>
  20. #include <set>
  21. #include <bitset>
  22. #include <cstdlib>
  23. #include <ctime>
  24. using namespace std;
  25.  
  26. #define lson l, mid, rt << 1
  27. #define rson mid + 1, r, rt << 1 | 1
  28. typedef long long ll;
  29. const int N = 1e5 + 10;
  30. const int INF = 0x3f3f3f3f;
  31. const int MOD = 1e9 + 7;
  32. const double EPS = 1e-8;
  33.  
  34. int main(void) {
  35. int a, b; scanf ("%d%d", &a, &b);
  36. int ans = min (a, b);
  37. printf ("%d ", ans);
  38. a -= ans, b -= ans;
  39. ans = a / 2 + b / 2;
  40. printf ("%d\n", ans);
  41.  
  42. return 0;
  43. }

水 B - Luxurious Houses

从后往前,维护一个后缀最大值

  1. /************************************************
  2. * Author :Running_Time
  3. * Created Time :2015/9/28 星期一 16:58:21
  4. * File Name :B.cpp
  5. ************************************************/
  6.  
  7. #include <cstdio>
  8. #include <algorithm>
  9. #include <iostream>
  10. #include <sstream>
  11. #include <cstring>
  12. #include <cmath>
  13. #include <string>
  14. #include <vector>
  15. #include <queue>
  16. #include <deque>
  17. #include <stack>
  18. #include <list>
  19. #include <map>
  20. #include <set>
  21. #include <bitset>
  22. #include <cstdlib>
  23. #include <ctime>
  24. using namespace std;
  25.  
  26. #define lson l, mid, rt << 1
  27. #define rson mid + 1, r, rt << 1 | 1
  28. typedef long long ll;
  29. const int N = 1e5 + 10;
  30. const int INF = 0x3f3f3f3f;
  31. const int MOD = 1e9 + 7;
  32. const double EPS = 1e-8;
  33. int a[N], mx[N], ans[N];
  34.  
  35. int main(void) {
  36. int n; scanf ("%d", &n);
  37. for (int i=1; i<=n; ++i) {
  38. scanf ("%d", &a[i]);
  39. }
  40. mx[n] = a[n]; ans[n] = 0;
  41. for (int i=n-1; i>=1; --i) {
  42. if (a[i] <= mx[i+1]) {
  43. ans[i] = mx[i+1] + 1 - a[i];
  44. }
  45. mx[i] = max (mx[i+1], a[i]);
  46. }
  47.  
  48. for (int i=1; i<=n; ++i) {
  49. printf ("%d%c", ans[i], i == n ? '\n' : ' ');
  50. }
  51.  
  52. return 0;
  53. }

  

贪心 C - Developing Skills

题意:给n个数,最多可以增加k,每个数上限为100,问max sum (a[i] / 10)

分析:若k很小时,优先加给需要最小数字能到下一个十整数的,按照这个规则排序。若还有多余则继续,此时每个数字加10,直到100或者k<=0,及时break。

  1. /************************************************
  2. * Author :Running_Time
  3. * Created Time :2015/9/28 星期一 16:58:28
  4. * File Name :C.cpp
  5. ************************************************/
  6.  
  7. #include <cstdio>
  8. #include <algorithm>
  9. #include <iostream>
  10. #include <sstream>
  11. #include <cstring>
  12. #include <cmath>
  13. #include <string>
  14. #include <vector>
  15. #include <queue>
  16. #include <deque>
  17. #include <stack>
  18. #include <list>
  19. #include <map>
  20. #include <set>
  21. #include <bitset>
  22. #include <cstdlib>
  23. #include <ctime>
  24. using namespace std;
  25.  
  26. #define lson l, mid, rt << 1
  27. #define rson mid + 1, r, rt << 1 | 1
  28. typedef long long ll;
  29. const int N = 1e5 + 10;
  30. const int INF = 0x3f3f3f3f;
  31. const int MOD = 1e9 + 7;
  32. const double EPS = 1e-8;
  33. int a[N];
  34.  
  35. int cal(int x) {
  36. if (x == 100) return 0;
  37. int a = x / 10;
  38. return (a + 1) * 10 - x;
  39. }
  40.  
  41. bool cmp(int x, int y) {
  42. return cal (x) < cal (y);
  43. }
  44.  
  45. int main(void) {
  46. int n, k; scanf ("%d%d", &n, &k);
  47. for (int i=1; i<=n; ++i) {
  48. scanf ("%d", &a[i]);
  49. }
  50. sort (a+1, a+1+n, cmp);
  51. while (k > 0) {
  52. bool up = false;
  53. for (int i=1; i<=n; ++i) {
  54. if (a[i] == 100) continue;
  55. int dt = cal (a[i]);
  56. if (dt > k || k <= 0) break;
  57. if (dt <= k) {
  58. k -= dt; a[i] += dt;
  59. up = true;
  60. }
  61. }
  62. if (!up) break;
  63. }
  64.  
  65. int ans = 0;
  66. for (int i=1; i<=n; ++i) {
  67. ans += a[i] / 10;
  68. }
  69. printf ("%d\n", ans);
  70.  
  71. return 0;
  72. }

  

模拟 D - Three Logos

题意:很好理解,就是三个矩形组合成一个正方形

分析:想到了很简单,无非就是两种情况,比赛时没想那么多,代码很挫,建议看图片就行了。。。

  1. /************************************************
  2. * Author :Running_Time
  3. * Created Time :2015/9/28 星期一 17:39:02
  4. * File Name :D.cpp
  5. ************************************************/
  6.  
  7. #include <cstdio>
  8. #include <algorithm>
  9. #include <iostream>
  10. #include <sstream>
  11. #include <cstring>
  12. #include <cmath>
  13. #include <string>
  14. #include <vector>
  15. #include <queue>
  16. #include <deque>
  17. #include <stack>
  18. #include <list>
  19. #include <map>
  20. #include <set>
  21. #include <bitset>
  22. #include <cstdlib>
  23. #include <ctime>
  24. using namespace std;
  25.  
  26. #define lson l, mid, rt << 1
  27. #define rson mid + 1, r, rt << 1 | 1
  28. typedef long long ll;
  29. const int N = 1e5 + 10;
  30. const int INF = 0x3f3f3f3f;
  31. const int MOD = 1e9 + 7;
  32. const double EPS = 1e-8;
  33.  
  34. int main(void) {
  35. int x[3], y[3];
  36. for (int i=0; i<3; ++i) {
  37. scanf ("%d%d", &x[i], &y[i]);
  38. if (x[i] > y[i]) swap (x[i], y[i]);
  39. }
  40. int sx = x[0] + x[1] + x[2];
  41. if (sx == y[0] && sx == y[1] && sx == y[2]) { //第一种情况
  42. printf ("%d\n", sx);
  43. for (int i=0; i<3; ++i) {
  44. for (int j=1; j<=x[i]; ++j) {
  45. for (int k=1; k<=y[i]; ++k) {
  46. printf ("%c", i == 0 ? 'A' : (i == 1) ? 'B' : 'C');
  47. }
  48. puts ("");
  49. }
  50. }
  51. }
  52. else { //第二种情况
  53. bool flag = false;
  54. int n = 0, id = 0;
  55. for (int i=0; i<3; ++i) {
  56. if (n < y[i]) {
  57. n = y[i]; id = i;
  58. }
  59. }
  60. int tx = n - x[id];
  61. for (int i=0; i<3; ++i) {
  62. for (int j=0; j<3; ++j) {
  63. if (i == id || j == id) continue;
  64. if (x[i] == x[j] && x[i] == tx) {
  65. if (y[i] + y[j] == n) {
  66. flag = true; break;
  67. }
  68. }
  69. else if (x[i] == y[j] && x[i] == tx) {
  70. if (y[i] + x[j] == n) {
  71. flag = true; break;
  72. }
  73. }
  74. else if (y[i] == x[j] && y[i] == tx) {
  75. if (x[i] + y[j] == n) {
  76. flag = true; break;
  77. }
  78. }
  79. else if (y[i] == y[j] && y[i] == tx) {
  80. if (x[i] + x[j] == n) {
  81. flag = true; break;
  82. }
  83. }
  84. }
  85. }
  86.  
  87. if (flag) { //输出答案
  88. printf ("%d\n", n);
  89. for (int i=1; i<=x[id]; ++i) {
  90. for (int j=1; j<=y[id]; ++j) {
  91. printf ("%c", id == 0 ? 'A' : (id == 1) ? 'B' : 'C');
  92. }
  93. puts ("");
  94. }
  95. char p, q;
  96. if (id == 0) p = 'B', q = 'C';
  97. else if (id == 1) p = 'A', q = 'C';
  98. else p = 'A', q = 'B';
  99. for (int i=0; i<3; ++i) {
  100. for (int j=0; j<3; ++j) {
  101. if (i == id || j == id) continue;
  102. if (x[i] == x[j] && x[i] == tx) {
  103. if (y[i] + y[j] == n) {
  104. for (int k=1; k<=tx; ++k) {
  105. for (int l=1; l<=n; ++l) {
  106. printf ("%c", l <= y[i] ? p : q);
  107. }
  108. puts ("");
  109. }
  110. return 0;
  111. }
  112. }
  113. else if (x[i] == y[j] && x[i] == tx) {
  114. if (y[i] + x[j] == n) {
  115. for (int k=1; k<=tx; ++k) {
  116. for (int l=1; l<=n; ++l) {
  117. printf ("%c", l <= y[i] ? p : q);
  118. }
  119. puts ("");
  120. }
  121. return 0;
  122. }
  123. }
  124. else if (y[i] == x[j] && y[i] == tx) {
  125. if (x[i] + y[j] == n) {
  126. for (int k=1; k<=tx; ++k) {
  127. for (int l=1; l<=n; ++l) {
  128. printf ("%c", l <= x[i] ? p : q);
  129. }
  130. puts ("");
  131. }
  132. return 0;
  133. }
  134. }
  135. else if (y[i] == y[j] && y[i] == tx) {
  136. if (x[i] + x[j] == n) {
  137. for (int k=1; k<=tx; ++k) {
  138. for (int l=1; l<=n; ++l) {
  139. printf ("%c", l <= x[i] ? p : q);
  140. }
  141. puts ("");
  142. }
  143. return 0;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. else puts ("-1");
  150. }
  151.  
  152. return 0;
  153. }

 

最后老夫夜观星相,预测此次rating会超1700,为了能够在div2继续虐菜,“故意”hack失败。。

Codeforces Round #322 (Div. 2)的更多相关文章

  1. Codeforces Round #322 (Div. 2) D. Three Logos 暴力

    D. Three Logos Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/problem ...

  2. Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列

    C. Developing Skills Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  3. Codeforces Round #322 (Div. 2) B. Luxurious Houses 水题

    B. Luxurious Houses Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/pr ...

  4. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  5. Codeforces Round #322 (Div. 2) —— F. Zublicanes and Mumocrates

    It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The ...

  6. Codeforces Round #322 (Div. 2) E F

    E. Kojiro and Furrari 题意说的是 在一条直线上 有n个加油站, 每加一单位体积的汽油 可以走1km 然后每个加油站只有一种类型的汽油,汽油的种类有3种 求从起点出发到达终点要求使 ...

  7. 树形dp - Codeforces Round #322 (Div. 2) F Zublicanes and Mumocrates

    Zublicanes and Mumocrates Problem's Link Mean: 给定一个无向图,需要把这个图分成两部分,使得两部分中边数为1的结点数量相等,最少需要去掉多少条边. ana ...

  8. Codeforces Round #322 (Div. 2) D. Three Logos 模拟

                                                      D. Three Logos Three companies decided to order a ...

  9. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

随机推荐

  1. run as maven test报错解决办法

    eclipse中使用maven插件的时候,运行run as maven build的时候报错 -Dmaven.multiModuleProjectDirectory system propery is ...

  2. Ajax的简单实现(Json)

    之前写的是一般的Ajax if (request.status === 200) { document.getElementById("createResult").innerHT ...

  3. Javascript对象的技巧和陷阱

    创建对象的3种方法 方法1 直接创建 var obj = { name: "mike", age: 10 } 方法2 用new创建 var ob = new Date(); 方法3 ...

  4. Design Pattern 设计模式1 - Strategy 1

    实现 : Defferent Heros attack Defferently. - 不同的英雄使用不用的招数 Strategy设计的思路: 基类A.更加小的基类B,新的继承类C: 1 从基类A中抽出 ...

  5. Python 001- 将URL中的汉字转换为url编码

    很多时候想爬取网页信息,结果出现URL是中文的情况(比如‘耳机'),url的地址编码却是%E8%80%B3%E6%9C%BA,因此需要做一个转换.这里我们就用到了模块urllib. 代码超简单 #-* ...

  6. MVC Hidden用法

    @Html.Hidden("DataSeriID",ViewBag.DataSeriID as string) 第一个参数相当于生成的ID值,后面的参数是String类型的数据,V ...

  7. es 300G 数据删除 执行计划 curl REST 操作

    es 300G 数据删除 [es union_2017执行计划] [测试执行环境]线上D服务器[测试用例]get:curl -XGET ES:9200/_cat/indices?v post:curl ...

  8. this that 时间戳转日期 小程序 列表 与 加载

    var gd = getApp().globalData; var imgUrlApp = gd.imgUrlApp; var localImgPath = gd.localImgPath; var ...

  9. An O(ND) Difference Algorithm and Its Variations (1986)

    http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927 The problems of finding a longest com ...

  10. mysql数据库引擎InnoDB和MyISAM的区别

    InnoDB支持行级锁和表级锁(默认行级锁),支持事务,外部键等:大量的insert和update更快等.只有通过索引条件检索数据,InnoDB 才使用行级锁,否则,InnoDB 将使用表锁. MyI ...