题干:1084 Broken Keyboard (20 分) 1085 Perfect Sequence (25 分)
题解:别刷甲级1084之前的题目,后面的题目做好就行了,前面的题目不太稳定而且有超纲。。。1084是我很早之前做的,1085是我今天做的,用了30分钟,拿了22分,后面10分钟都是在改一个超时的点,但是没有改出来。。。
我有的博客内容一般写得比较多,但是每篇都重复写会有点烦。。。想看更多心路历程的朋友进这个链接https://blog.csdn.net/qq_30753921?spm=1011.2124.3001.5343
#include<bits/stdc++.h>
using namespace std;
deque<char> an;
int bn[257]={0};
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
bool cmp(char a,char b){
return a<b;
}
int main(int argc, char** argv) {
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
string s1, s2, ans;
cin >> s1 >> s2;
for (int i = 0; i < s1.length(); i++)
if (s2.find(s1[i]) == string::npos && ans.find(toupper(s1[i])) == string::npos)
ans += toupper(s1[i]);
cout << ans;
return 0;
}
// A1085.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <bits/stdc++.h>
using namespace std;
vector<long long> an;
bool cmp(long long x, long long y) {
return x > y;
}
int main()
{
#ifndef ONLINE_JUDGE
#pragma warning(disable:4996)
FILE* s;
freopen_s(&s,"in.txt", "r", stdin);
#endif // !ONLINE_JUDGE
int n, p; long long t;
cin >> n >> p;
for (int i = 0; i < n; i++) {
scanf("%lld", &t);
an.push_back(t);
}
sort(an.begin(), an.end(), cmp);
int max = -1;
int count = 1;
int len=INT_MAX;
for (int i = 0; i < an.size()&& len>max; i++) {
int len = an.size() - 1 - i;
if (len > max) {
for (int j = i + 1; j < an.size(); j++) {
if (an[i] <= an[j] * p) {
count++;
}
}
if (count > max) {
max = count;
}
count = 1;
}
}
cout << max;
return 0;
}