当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
[Kali Security Penetration Testing Practice Tutorial] Chapter 6 Password Attack
三极管开关电路参数设计与参数介绍
实例046:打破循环
ArcGIS Advanced (1) - Install ArcGIS Enterprise and create an sde library
2022.8.9考试独特的投标拍卖--800题解
Example 046: Breaking the Cycle
yolov5+usb相机
新零售社交电商APP系统平台如何打造公域+私域流量?
Day16 charles的基本使用
网路编程_调试accept
2022.8.8考试游记总结
2022.8.8考试清洁工老马(sweeper)题解
Excel Advanced Drawing Skills 100 Lectures (23) - Countdown Counting in Excel
[Kali Security Penetration Testing Practice Course] Chapter 9 Wireless Network Penetration
what is a microcontroller or mcu
维度表设计
P1564 膜拜
what is eabi
Arcgis进阶篇(1)——安装Arcgis Enterprise,创建sde库
Example 043: Scope, class methods and variables