CF上给的标签是数据结构.但给的题解里的方法是很巧的暴力,用vector<set>维护每个字母出现的下标,每次修改加下标,擦下标.每次询问对每个字母分别lower_bound查找区间内是否存在这样位置,实在太妙了! 先看题解的方法. #include <bits/stdc++.h> #define debug(x) cout << #x << ": " << x << endl using namespace st…
题目链接:Round #590 题目答案:官方Editorial.My Solution A. Equalize Prices Again 签到题还WA了一发,向上取整有点问题: //my wrong code, 1.0 * sum返回double ceil(1.0 * sum / n); //right code (int)ceil(1.0 * sum / n); //ceil()原型 double ceil(double x); float能保证6位精度(有效数字),double能保证15位…
A. Equalize Prices Again 题目链接:https://codeforces.com/contest/1234/problem/A 题意:给你 n 个数 , 你需要改变这些数使得这 n 个数的值相等 , 并且要求改变后所有数的和需大于等于原来的所有数字的和 , 然后输出满足题意且改变后最小的数值 分析: 签到题.记原来 n 个数的和为 sum , 先取这些数的平均值 ave , 然后每次判断 ave * n >= sum 是否成立成立则直接输出 , 不成立将 ave ++ #…
https://codeforces.com/contest/1234/problem/A A. Equalize Prices Again #include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n,a; int t; cin>>t; ll sum = ,ans; while(t--){ cin>>n;sum = ; ;i < n;++i){ cin&g…
Codeforces Round #590 (Div. 3) Editorial 题目链接 官方题解 不要因为走得太远,就忘记为什么出发! Problem A 题目大意:商店有n件商品,每件商品有不同的价格,找出一个最小的可能值price,使得price * n >= sum,sum指的是原来商品价格的总和. 知识点:模拟 思路:求出sum/n向上取整即可,有两种方法.一是使用ceil()函数,但注意ceil()返回的是向上取整后的浮点数,所以要进行强制类型转换:二是直接向下取整,然后用if语句…
链接: https://codeforces.com/contest/1234/problem/D 题意: You are given a string s consisting of lowercase Latin letters and q queries for this string. Recall that the substring s[l;r] of the string s is the string slsl+1-sr. For example, the substrings…
链接: https://codeforces.com/contest/1234/problem/C 题意: You are given a system of pipes. It consists of two rows, each row consists of n pipes. The top left pipe has the coordinates (1,1) and the bottom right - (2,n). There are six types of pipes: two…
链接: https://codeforces.com/contest/1234/problem/A 题意: You are both a shop keeper and a shop assistant at a small nearby shop. You have n goods, the i-th good costs ai coins. You got tired of remembering the price of each product when customers ask fo…
链接: https://codeforces.com/contest/1234/problem/E 题意: Let's define pi(n) as the following permutation: [i,1,2,-,i−1,i+1,-,n]. This means that the i-th permutation is almost identity (i.e. which maps every element to itself) permutation but the elemen…
链接: https://codeforces.com/contest/1234/problem/B2 题意: The only difference between easy and hard versions are constraints on n and k. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most k most…