Problem - A - CodeforcesYou are given nn integers a1,a2,…,an. Find the maximum value of max(al,al+1,…,ar)⋅min(al,al+1,…,ar)over all pairs (l,r)of integers for which 1≤l&l
转载
2024-06-30 10:55:02
60阅读
A. Winner 题目地址:http://codeforces.com/contest/2/problem/A 题目大意:给出每一次比赛的得分情况,问最后得分最高的人。若最后分数同样,则输出分数同样的人中第一个分数不小于最后最高分
题目链接:https://codeforces.com/problemset/problem/1439/B解题思路:很容易想到和拓扑排序类似的思路,删点判断答案。关键在于如何判断度数为k-1的完全图,这个地方只需要再每次删点之前判断一下就好了//#define LOCAL
#include <bits/stdc++.h>
using namespace std;
#define ll
转载
2024-04-03 08:27:04
453阅读
A、题意:一个士兵要买香蕉,第1个香蕉价格是k,第二个香蕉价格是2k,以此类推,现在士兵有钱n要买w个香蕉,问他需要像朋友借多少钱才能买到香蕉解:ans=max((1+w)*w/2*k-n, 0);1 /*
2 * Problem:
3 * Author: SHJWUDP
4 * Created Time: 2015/6/24 星期三 13:24:16
5 * File N
转载
2024-05-15 12:51:24
217阅读
883D题面题目大意:给你一个长度为n的字符串,上面有牛(“P”),草(“*”)和空地(“.”)。现在你给每一头牛规定一个方向,它会一直往前吃草,直到走到边界。每一份草只会被吃1次,要求输出最多吃多少草,以及在此基础下吃完最后一份草的最小时间。n<=1000000。做法:很明显两头牛就可以吃完所有草,于是暴力处理0,1头牛的情况。然后由于具有单调性,考虑二分答案后贪心(时限3s不虚)。接下来
转载
2024-08-06 20:56:16
116阅读
A - Split it!检查 \(k=0\) 或者长 \(k\) 的前缀和长 \(k\) 的后缀的反串是否相同。注意如果 \(2k=n\) 要特判。复杂度 \(O(n+k)\)。B - Max and Mex模拟一下过程就会发现:要么 \(\max\) 和 \(\operatorname{max}\) 永远不会变,要么就会一直加 \(1\)。所以答案只有可能是 \(n,n+1,n+k\) 中的一
转载
2021-03-11 08:31:03
313阅读
2评论
一、解题思路1.A. Technical Support——1754A题目分析:题目给定了一串字符串,字符串包含了两种字符一个为‘Q’表示问题,另一个字符'A'表示回答问题,题目要求输出是否对于每个问题,都做出了解答,若是输出YES,否则输出NO。注意:对于一个问题可以有多个回答,一个问题可以被延后回答。思路:遍历字符串统计问题和回答是否匹配,若当前字符为‘Q’则统计次数加一,代表需要回答的问题加
比赛链接:http://codeforces.com/contest/854A. Fraction解法:按照题意模拟即可。#include <bits/stdc++.h>using namespace std;int main(){ int n; cin >> n; for(int i=n/2; i>=1; i--){ if(__gcd
原创
2022-04-19 10:20:25
32阅读
A题 关注到本题的数据量不大但是数据很大,可以使用暴力+哈希的方法 将关闭的餐厅放到map遍历 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<map> #
转载
2020-01-20 11:42:00
91阅读
A题 只需要找到A中后面跟的最长的p串是几个即可 #include<iostream> #include<cstring> #include<string> #include<map> #include<vector> #include<cstdio> using namespace std; in
转载
2020-01-12 21:28:00
90阅读
Codeforces 题解
转载
2021-03-10 14:52:00
106阅读
2评论
A题 对于两个分别求解到每一位的时间,看看是否有相等的 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pll; const int N=2e5+10; const in
转载
2021-03-18 10:46:00
91阅读
2评论
A题 先除再计算即可 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pll; typedef pair<int,int> plll; const int N=3e5+1
转载
2020-12-25 22:16:00
110阅读
2评论
A题 枚举每一位,如果是偶数就加上i #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pll; const int N=2e5+10; int main(){ ios::
转载
2020-12-24 19:13:00
49阅读
2评论
A题 循环构造bac即可,因为题目是小于等于,我看成了等于所以构造的复杂了点 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int main(){ ios::sync_with_stdio(false); int t
转载
2021-01-19 10:50:00
70阅读
2评论
A题 排序输出答案即可 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pll; const int N=4e5+10; const int inf=1e9; int a
转载
2020-12-22 18:47:00
59阅读
2评论
A题 通过平移线段可以发现其实就是缺少的那一块的大小 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pll; const int N=5e5+10; int main(
转载
2020-12-21 22:21:00
64阅读
2评论
A题 贪心思路,注意到他们每个是每个排列进行比较,因此只要判断两个字符串对应位置的大小,谁多就谁赢 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pll; const
转载
2020-12-20 20:12:00
66阅读
2评论
A题: 我们发现如果任意两个奇偶性不同都不行,因为只要奇偶相同,都能够通过加2操作得到 #include<iostream> #include<queue> #include<map> #include<vector> #include<cstdio> #include<algorithm> #in
转载
2020-03-14 08:13:00
80阅读
2评论
A题 本题根据题意模拟能解,不排除更好的做法 #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<vector> #include<cstring> using namespace std;
转载
2020-02-02 12:04:00
72阅读
2评论