当前位置:网站首页>uva1392
uva1392
2022-08-10 02:45:00 【小刀刺大熊】
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 2e5 + 7;
int cnt[maxn] = {
0 }, nmax[maxn] = {
0}, sum[maxn] = {
0 }, n, p;
char a[maxn], b[maxn];
bool ok(long long int mid) {
for (int i = mid; i <= n; i++) {
if (sum[i] <= nmax[i - mid]) return true;
}
return false;
}
int main() {
while (cin >> n >> p && n && p) {
cin >> a >> b;
for (int i = 0; i < n; i++) {
cnt[i + 1] = cnt[i] + (a[i] != b[i]);
}
for (int i = 1; i <= n; i++) sum[i] = 100 * cnt[i] - p * i;
for (int i = 1; i <= n; i++) nmax[i] = max(nmax[i - 1], sum[i]);
int l = 0, r = n;
while (l < r) {
int mid = (l + r + 1) >> 1;
if (ok(mid)) {
l = mid;
}
else r = mid - 1;
}
if (!l) cout << "No solution." << endl;
else cout << l << endl;
}
return 0;
}
边栏推荐
- flex 的 三个参数:flex-grow、flex-shrink、flex-basis
- 从8k到13k,我全靠这本《接口自动化测试——从入门到精通》
- What makes training multi-modal classification networks hard?
- uni-app自定义导航栏
- Chip Accelerator
- 2022.8.8考试从记忆中写入(memory)题解
- 从滑动标尺模型看企业网络安全能力评估与建设
- Excel Advanced Drawing Skills 100 Lectures (23) - Countdown Counting in Excel
- Arrays类
- plsql 查询数据库操作历史记录(Ctrl + e)
猜你喜欢
MySQL:日志系统介绍 | 错误日志 | 查询日志 | 二进制日志:bin-log数据恢复实践 | 慢日志查询
The Evolutionary History of the "Double Gun" Trojan Horse Virus
使用注解实现限流
新零售社交电商APP系统平台如何打造公域+私域流量?
Example 045: Summation
将信号与不同开始时间对齐
【图像分类】2022-ConvMixer ICLR
Example 043: Scope, class methods and variables
[Kali Security Penetration Testing Practice Tutorial] Chapter 6 Password Attack
What makes training multi-modal classification networks hard?
随机推荐
Chapter 21 Source Code File REST API Reference (3)
兴业数金一面
The IDEA to automatically generate the serialVersionUID
官宣出自己的博客啦
storage of data in memory
论文理解:“PIAT: Physics Informed Adversarial Training for Solving Partial Differential Equations“
《天才基本法》:平行时空的第二次选择,小演员的表现意外出圈
plsql 查询数据库操作历史记录(Ctrl + e)
fastjson autoType is not support
盘式导电滑环的优点和缺点
从滑动标尺模型看企业网络安全能力评估与建设
What makes training multi-modal classification networks hard?
QT模态对话框及非模态对话框学习
驱动程序开发:无设备树和有设备树的platform驱动
Example 044: Matrix Addition
flutter 每天一背,需要掌握
2022.8.8考试从记忆中写入(memory)题解
flex 的 三个参数:flex-grow、flex-shrink、flex-basis
想要避免After Effects渲染失败的问题,5个小技巧必看
flutter 制作嵌套列表