A

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-10;
  11. const double EPS = 1.0e-4;
  12. typedef pair<int, int> pairint;
  13. typedef long long ll;
  14. typedef unsigned long long ull;
  15. //const int maxn = 3e5 + 10;
  16. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  17. //priority_queue<int, vector<int>, less<int>> que;
  18. //next_permutation
  19. string a;
  20. int anser = ;
  21. int main()
  22. {
  23. int n;
  24. cin >> n;
  25. cin >> a;
  26. int len = a.size();
  27. for (int i = ; i < len - ; i++)
  28. {
  29. if (a[i] == a[i + ] && a[i] != '?')
  30. {
  31. cout << "No" << endl;
  32. return ;
  33. }
  34. }
  35. if (a[] == '?' || a[len - ] == '?')
  36. {
  37. cout << "Yes" << endl;
  38. return ;
  39. }
  40. for (int i = ; i < len - ; i++)
  41. {
  42. if (a[i] == '?' && (a[i - ] == a[i + ]))
  43. {
  44. cout << "Yes" << endl;
  45. return ;
  46. }
  47. }
  48. for (int i = ; i < len - ; i++)
  49. {
  50. if (a[i] == a[i + ] && a[i] == '?')
  51. {
  52. cout << "Yes" << endl;
  53. return ;
  54. }
  55. }
  56. cout << "No" << endl;
  57. }

B

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-10;
  11. const double EPS = 1.0e-4;
  12. typedef pair<int, int> pairint;
  13. typedef long long ll;
  14. typedef unsigned long long ull;
  15. //const int maxn = 3e5 + 10;
  16. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  17. //priority_queue<int, vector<int>, less<int>> que;
  18. //next_permutation
  19. char f[][];
  20. int hang[];
  21. int main()
  22. {
  23. int n, m;
  24. int sum = ;
  25. cin >> n >> m;
  26. for (int i = ; i <= n; i++)
  27. {
  28. scanf("%s", f[i] + );
  29. }
  30. for (int i = ; i <= n; i++)
  31. {
  32. if (hang[i])
  33. {
  34. continue;
  35. }
  36. for (int j = ; j <= m; j++)
  37. {
  38. if (f[i][j] == '#')
  39. {
  40. //cout << i << " " << j << endl;
  41. for (int k = ; k <= n; k++)
  42. {
  43. if (k == i)
  44. {
  45. continue;
  46. }
  47. if (f[k][j] == '#')
  48. {
  49. // cout << "find" << k << " " << j << endl;
  50. for (int w = ; w <= m; w++)
  51. {
  52. if (f[k][w] != f[i][w])
  53. {
  54. cout << "No" << endl;
  55. return ;
  56. }
  57. }
  58. hang[k] = ;
  59. }
  60. }
  61. }
  62. }
  63. }
  64. cout << "Yes" << endl;
  65. return ;
  66. }

C

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-10;
  11. const double EPS = 1.0e-4;
  12. typedef pair<int, int> pairint;
  13. typedef long long ll;
  14. typedef unsigned long long ull;
  15. //const int maxn = 3e5 + 10;
  16. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  17. //priority_queue<int, vector<int>, less<int>> que;
  18. //next_permutation
  19. int num[];
  20. int main()
  21. {
  22. double anser = -;
  23. int n, u;
  24. cin >> n >> u;
  25. num[n + ] = INT_MAX;
  26. for (int i = ; i <= n; i++)
  27. {
  28. scanf("%d", num + i);
  29. }
  30. for (int i = ; i <= n - ; i++)
  31. {
  32. int now = num[i];
  33. int cha = num[i + ] - num[i];
  34. int aim = upper_bound(num + , num + n + , num[i] + u) - num - ;
  35. if (aim - i <= || aim > n)
  36. {
  37. continue;
  38. }
  39. //cout << i << " " << aim << endl;
  40. anser = max(anser, (double)(num[aim] - num[i] - cha) / (double)(num[aim] - num[i]));
  41. }
  42. if (anser == -)
  43. {
  44. cout << anser << endl;
  45. }
  46. else
  47. {
  48. printf("%.10f\n", anser);
  49. }
  50. return ;
  51. }

D

假设在第i次量的时候的总标记数为sum[i] 可知其必定为非递减函数 sum[i]=d[i]+m[i]+1

要使d[i]的总值最小则 要在m[i]+1上面再加数使得 m[i]>=m[i-1]&&m[i+1]-1<=m[i]<=m[i+1]

先从前往后扫一遍满足第一个条件 再从往前扫一遍满足第二个条件

注意要开LL

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-10;
  11. const double EPS = 1.0e-4;
  12. typedef pair<int, int> pairint;
  13. typedef long long ll;
  14. typedef unsigned long long ull;
  15. //const int maxn = 3e5 + 10;
  16. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  17. //priority_queue<int, vector<int>, less<int>> que;
  18. //next_permutation
  19. ll num[];
  20. int main()
  21. {
  22. int n;
  23. cin >> n;
  24. ll maxn = - ;
  25. ll ans = ;
  26. for (int i = ; i <= n; i++)
  27. {
  28. scanf("%lld", num + i);
  29. maxn = max(maxn, num[i]);
  30. }
  31. for (int i = ; i <= n - ; i++)
  32. {
  33. if (num[i + ] < num[i])
  34. {
  35. ans += num[i] - num[i + ];
  36. num[i + ] = num[i];
  37. }
  38. }
  39. for (int i = n; i >= ; i--)
  40. {
  41. if (num[i] - num[i - ] > )
  42. {
  43. ans += num[i] - - num[i - ];
  44. num[i - ] = num[i] - ;
  45. }
  46. }
  47. cout << ans << endl;
  48. return ;
  49. }

Codeforces 957 水位标记思维题的更多相关文章

  1. CF--思维练习-- CodeForces - 215C - Crosses(思维题)

    ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered fr ...

  2. Codeforces 675C Money Transfers 思维题

    原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每 ...

  3. Codeforces 1090D - Similar Arrays - [思维题][构造题][2018-2019 Russia Open High School Programming Contest Problem D]

    题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of ...

  4. codeforces 1140D(区间dp/思维题)

    D. Minimum Triangulation time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  5. ACM思维题训练 Section A

    题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...

  6. codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题

    http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...

  7. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  8. C. Nice Garland Codeforces Round #535 (Div. 3) 思维题

    C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  9. CodeForces - 631C ——(思维题)

    Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...

随机推荐

  1. Vue/Element-ui 安装搭建开发环境(一)

    Element 是饿了么全段开发团队推出的一套基于 vue.js2.0 的 PC Web 端开发框架. Element 中文文档:https://element.eleme.cn/#/zh-CN 1. ...

  2. File类 ReadAllBytes() ReadAllLines() ReadAllText()

    用 File 类里的 ReadAllLines方法读取文件string[] contents = File.ReadAllLines(@"F:\Users\zhuotu003\Desktop ...

  3. nginx location的优先级

    原来一直以为location的优先级是先后顺序,结果有次项目中傻眼了,赶紧百度一下,下面的内容参考了这个链接 location表达式类型 ~ 表示执行一个正则匹配,区分大小写~* 表示执行一个正则匹配 ...

  4. iOS SDK开发之 .framework静态库

    查看.a静态库的生成及使用单击此处 注:这篇教程将只使用一小部分Objective-C代码,本文主要讲解从开始到应用的详细步骤.环境:xcode 9.2下面我们开始操作: 第一步:创建一个静态库工程 ...

  5. kafka 通信报文格式

    1. 序列化一条消息 消息有 key 和 value kafka 提供了基础数据类型的序列化工具,对于业务的自定义类需要自行实现序列化 ProducerRecord 是对象,含 KV 和 header ...

  6. 【Python】我的豆瓣短评爬虫的多线程改写

    对之前我的那个豆瓣的短评的爬虫,进行了一下架构性的改动.尽可能实现了模块的分离.但是总是感觉不完美.暂时也没心情折腾了. 同时也添加了多线程的实现.具体过程见下. 改动 独立出来的部分: MakeOp ...

  7. 【Linux开发】【Qt开发】交叉编译器 arm-linux-gnueabi 和 arm-linux-gnueabihf 的区别

    一. 什么是ABI和EABI1) ABI: 二进制应用程序接口(Application Binary Interface (ABI) for the ARM Architecture)在计算机中,应用 ...

  8. django中使用原生的orm

    只有用的时候才能执行

  9. Js AJAX Event

    ;(function () { if ( typeof window.CustomEvent === "function" ) return false; function Cus ...

  10. 【嵌入式 Linux文件系统】如何使用NFS文件系统

    (1)内核配置 取消选项 General setup-->Initial RAM filesystem and RAM disk (initramfs/initrd) support 进入Fil ...