A. Reverse a Substring

代码:

#include <bits/stdc++.h>
using namespace std; int N;
string s; int main() {
scanf("%d", &N);
cin >> s; int temp = -;
for(int i = ; s[i]; i ++) {
if(s[i] < s[i - ]) {
temp = i;
break;
}
} if(temp == -) printf("NO\n");
else {
printf("YES\n");
temp += ;
printf("%d %d\n", temp - , temp);
} return ;
}

B. Game with Telephone Numbers

代码:

#include <bits/stdc++.h>
using namespace std; int N;
int eight = ;
string s; int main() {
scanf("%d", &N);
cin >> s;
bool flag = true;
for(int i = ; i <= N - ; i ++) {
if(s[i] == '')
eight ++;
}
if(eight <= ((N - ) / )) flag = false; if(flag) printf("YES\n");
else printf("NO\n"); return ;
}

C. Alarm Clocks Everywhere

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 3e5 + ;
int N, M;
long long a[maxn], p[maxn], b[maxn]; long long gcd(long long a, long long b) {
return b == ? a : gcd(b, a % b);
} int main() {
scanf("%d%d", &N, &M);
long long t;
for(int i = ; i <= N; i ++) {
cin >> a[i];
//scanf("%lld", &a[i]);
if(i == ) b[i] = ;
else b[i] = a[i] - a[i - ];
} for(int i = ; i <= N; i ++) {
if(i == ) t = b[i];
else t = gcd(t, b[i]);
} bool flag = false;
int temp;
for(int i = ; i <= M; i ++) {
cin >> p[i];
//scanf("%lld", &p[i]);
if(t % p[i] == ) {
temp = i;
flag = true;
}
} int ansp = temp;
if(!flag) printf("NO\n");
else {
printf("YES\n");
cout << a[] << " " << ansp << endl;
} return ;
}

D. Beautiful Array

代码:(D 神仙 dp 自己写了贪心 但是不对有一些情况不可以 枯了 )

#include <bits/stdc++.h>
using namespace std; const int maxn = 3e5 + ;
long long a[maxn], dp[maxn][];
int N, K; int main() {
memset(dp, -1e18, sizeof(dp));
scanf("%d%d", &N, &K);
long long ans = ;
for(int i = ; i <= N; i ++) {
cin >> a[i];
dp[i][] = max(dp[i - ][], 0LL) + a[i];
dp[i][] = max(max(dp[i - ][], dp[i - ][]), 0LL) + 1LL * K * a[i];
dp[i][] = max(max(max(dp[i - ][], dp[i - ][]), dp[i - ][]), 0LL) + a[i];
ans = max(ans, max(dp[i][], max(dp[i][], dp[i][])));
}
cout << ans << endl;
return ;
}

 

Education CodeForces Round 63 Div.2的更多相关文章

  1. Educational Codeforces Round 63 Div. 2

    A:找到两个相邻字符使后者小于前者即可. #include<bits/stdc++.h> using namespace std; #define ll long long #define ...

  2. Codeforces Beta Round #63 (Div. 2)

    Codeforces Beta Round #63 (Div. 2) http://codeforces.com/contest/69 A #include<bits/stdc++.h> ...

  3. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  4. CF922 CodeForces Round #461(Div.2)

    CF922 CodeForces Round #461(Div.2) 这场比赛很晚呀 果断滚去睡了 现在来做一下 A CF922 A 翻译: 一开始有一个初始版本的玩具 每次有两种操作: 放一个初始版 ...

  5. Codeforces Round #545 (Div. 1) 简要题解

    这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...

  6. Codeforces Round #455 (Div. 2)

    Codeforces Round #455 (Div. 2) A. Generate Login 题目描述:给出两个字符串,分别取字符串的某个前缀,使得两个前缀连起来的字符串的字典序在所有方案中最小, ...

  7. Codeforces Round #556 (Div. 1)

    Codeforces Round #556 (Div. 1) A. Prefix Sum Primes 给你一堆1,2,你可以任意排序,要求你输出的数列的前缀和中质数个数最大. 发现只有\(2\)是偶 ...

  8. [Educational Codeforces Round 63 ] D. Beautiful Array (思维+DP)

    Educational Codeforces Round 63 (Rated for Div. 2) D. Beautiful Array time limit per test 2 seconds ...

  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. Java枚举:小小enum,优雅而干净

    <Java编程思想>中有这么一句话:“有时恰恰因为它,你才能够‘优雅而干净’地解决问题”——这句话说的是谁呢?就是本篇的主角——枚举(Enum)——大家鼓掌了. 在之前很长时间一段时间里, ...

  2. WebApiClient的JsonPatch局部更新

    1. 文章目的 随着WebApiClient的不断完善,越来越多开发者选择WebApiClient替换原生的HttpClient,本文将介绍使用WebApiClient来完成JsonPatch提交的新 ...

  3. 记一次按需加载和npm模块发布实践

    按需加载 在使用 lodash 的时候我们可以使用这样的代码 //一 import {omit} from "lodash"; //二 import l from "lo ...

  4. Java设计模式---ChainOfResponsibility责任链模式

    参考于 : 大话设计模式 马士兵设计模式视频 代码参考于马士兵设计模式视频 写在开头:职责链模式:使多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合关系 图来自大话设计模式,下面我的代 ...

  5. es6 proxy代理

    es6 新增构造函数 Proxy Proxy 构造函数,可以使用new 去创建,可以往里面插入两个参数,都是对象 let target = {} let handler = {} let proxy ...

  6. js将一个数组分成多个数组

    1,将数组array分成长度为subGroupLength的小数组并返回新数组 function group(array, subGroupLength) { let index = 0; let n ...

  7. 安装centos5.x的基本优化配置

    1.添加账号

  8. SAP MM 采购ERP顾问咨询费限制总金额的框架协议实现方案

    SAP MM 采购ERP顾问咨询费限制总金额的框架协议实现方案 [业务场景] 采购部门与ERP咨询公司签订了一个框架协议,只规定不同级别顾问的人天费用,不限定这些不同级别咨询顾问的具体采购的人天数,但 ...

  9. asp.net mvc 5发布部署遇到403.14

    asp.net mvc 5发布部署遇到403.14? HTTP错误 403.14 服务器配置为不列出此目录内容 除了设置.net运行的权限 isap和cgi启动状态外.可能是因为你手贱. 将这个钩去掉 ...

  10. 使用Android服务,实现报警管理器和广播接收器

    介绍 几乎在所有平台上都有很多进程运行背景,它们被称为服务.可能在Android平台中有一些服务可以执行长时间运行的操作,这些操作在处理时不需要用户交互. 在本文中,借助预定义的Android警报服务 ...