Codeforces Round 894 (Div. 3)

A. Gift Carpet

题意:判断一列一个字母有没有“vika”

思路:挨个枚举每一列

#include<bits/stdc++.h>
using namespace std;
char mp[25][25];
char x[]={'v','i','k','a'};
void solve()
{
int m,n;
cin>>m>>n;
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
cin>>mp[i][j];
}
}
if(n<4){
cout<<"NO"<<endl;
return;
}
int res=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(mp[j][i]==x[res]){
res++;
break;
}
}
}
if(res==4) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
int main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

B. Sequence Game

题意:操作:删除a[i];结果:给的数组满足a[i]<=a[i+1]

思路:找到a[i]>a[i+1]插入1

#include <bits/stdc++.h>
using namespace std;
const int MAX=4e5;
int a[MAX];
void solve()
{
int n,old,res=1;
cin>>n>>old;
a[0]=old;
for(int i=1;i<n;i++){
int ne;
cin>>ne;
if(old>ne){
a[res]=1;
res++;
}
old=ne;
a[res]=old;
res++;
}
cout<<res<<endl;
for(int i=0;i<res;i++){
cout<<a[i]<<" ";
}
cout<<endl;
}
int main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

C. Flower City Fence

题意:n个宽为1长为a[i]的长方形组成了一个大图,他对称是否重合

思路:只需要他的高度和数量相同就行(画个图就理解了)

#include <bits/stdc++.h>
using namespace std;
const int MAX=2e5+10;
int a[MAX],b[MAX];
void solve()
{
memset(b,0,sizeof(b));
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for (int i = 1; i <= n; ++i)
{
if (a[i] > n)
{
cout<<"NO\n";
return;
}
b[a[i]] = i;
}
for (int i = n; i >= 1; --i)
{
b[i] = max(b[i], b[i + 1]);
if (a[i] != b[i])
{
cout<<"NO\n";
return;
}
}
cout<<"YES\n";
}
int main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

D. Ice Cream Balls

题意:选择n个数使得两两组合的方案数为n

思路:两个不同的数可组成的方案数是s*(s-1);后面再加入和之前集合中的数相同的数(增加的方案是(s,s)),先二分找到s然后再相加

#include <bits/stdc++.h>
using namespace std;
void solve() {
long long int n;
cin >> n;
long long int l = 2, r = 2e+10;
while (l < r) {
long long int mid = (l + r) / 2;
if (mid * (mid - 1) / 2 < n)
l = mid + 1;
else
r = mid;
}
if (l * (l - 1) / 2 == n)
cout << l << "\n";
else {
long long int t = l - 1, s = t * (t - 1) / 2;
cout << t+n-s << "\n";
}
} int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}

E. Kolya and Movie Theatre

题意:满意度:(y-x+1)*d,求最大满意度是多少

思路:假设你看的电影场次分别为x,y,z;总要减去的满意度=(x-0)+(y-x)+(z-y)=z;即可得只需要枚举最后一场

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
multiset<int> st;
int a[200010];
void solve()
{
LL n, m, d, ans = 0, sum = 0;
scanf("%lld%lld%lld", &n, &m, &d);
st.clear();
for (int i = 1; i <= n; ++i)
{
scanf("%lld", &a[i]);
if (a[i] > 0 && st.size() < m)
{
st.insert(a[i]);
sum += a[i];
}
else if (*st.begin() < a[i])
{
sum -= *st.begin();
st.erase(st.begin());
sum += a[i];
st.insert(a[i]);
}
ans = max(ans, sum - i * d);
}
printf("%lld\n", ans);
}
signed main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

F. Magic Will Save the World

题意:一秒可以生成w个水魔法,f个火魔法,初值均为0,第i个怪兽有si点力量,要想打败它需要至少si点火魔法或者水魔法。求出至少要多少分钟来打败这n个怪兽

思路:在某一秒之后,水魔法和火魔法可以瞬间消灭所有的怪兽,其中水魔法消灭了若干只怪兽,火魔法消灭了若干怪兽,我们只要算出两种魔法分别消灭的怪兽的力量和,除以每秒产生的魔法数,分别向上取整,取大就能得到,当前怪兽分配的最小时间。

#include <bits/stdc++.h>
using namespace std;
bitset<1000005> bt;
void solve() {
bt.reset();
int w, f;
cin >> w >> f;
int ans = 0x3f3f3f3f;
int n;
cin >> n;
bt[0] = 1;
vector<int> s(n);
int tot = 0;
for (int i = 0; i < n; i++) {
cin >> s[i];
tot += s[i];
}
for (int i = 0; i < n; i++) {
bt |= bt << s[i];
}
for (int i = 0; i <= tot; i++) {
if (bt[i]) {
ans = min(ans, max((i + w - 1) / w, (tot - i + f - 1) / f));
}
}
cout << ans << '\n';
}
int main() {
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

Codeforces Round 894 (Div. 3)的更多相关文章

  1. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  7. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  8. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

  9. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

  10. 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts

    题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...

随机推荐

  1. 通过python,将excel中的数据写入二维列表

    需求:读取Excel表中数据,每行数据放在一个列表中,再把所有列表都存入到一个列表中,形成二维列表. 实现方法:导入可在Python处理Excel表格数据的模块. excel表: 方法一:xlwing ...

  2. Spring Boot通过企业邮箱发邮件被Gmail退回的问题解决方法

    这两天给我们开发的Chrome插件:Youtube中文配音增加了账户注册和登录功能,其中有一步是邮箱验证,所以这边会在Spring Boot后台给用户的邮箱发个验证信息.如果发邮件,之前的文章教程里就 ...

  3. 【双系统】Win10/Win11 引导 Ubuntu

    目录 纲要 注意 写在最前 1. Win 分区 2. Ubuntu刻盘 3. 安装 Ubuntu 4. 配置引导 纲要 本文主要介绍了如何在已安装 Win10/Win11 前提下安装 Ubuntu 双 ...

  4. 小白整理了VUEX

    在小白开发的项目中前端使用的是Vue,虽然在日常工作中可以使用Vue进行开发工作.但是没有系统的学习过Vue,对Vue的一些特性和方法使用时常常需要查询资料解决问题,查询资料常常会占用大量时间,尤其对 ...

  5. Jmeter读取结果文件报错Error loading results file解决方法

    最近在项目性能测试过程中,遇到jmeter读取jtl文件出错的问题,如下图所示: 方法一:修改配置文件 将要读取结果文件的组件Configure界面配置都勾选上,默认情况下有些选项没勾选会出错. 第一 ...

  6. 关于api数据接口应用

    在当今互联网时代,API数据接口应用已经成为各行各业不可替代的技术,它可以让开发者更加轻松地访问和使用各种功能和数据,从而提高开发效率和用户体验.下面就让我们来详细了解API数据接口应用的相关内容. ...

  7. 如何成功将 API 客户的 transformer 模型推理速度加快 100 倍

    Transformers 已成为世界各地数据科学家用以探索最先进 NLP 模型.构建新 NLP 模块的默认库.它拥有超过 5000 个预训练和微调的模型,支持 250 多种语言,任君取用.无论你使用哪 ...

  8. OpenSSL 生成 RootCA (根证书)并自签署证书(支持 IP 地址)

    背景 某机房内部访问需要配置 HTTPS,网上找的一些证书教程都不是特别好,有些直接生成证书,没有根 CA 的证书导致信任不了 Ubuntu 机器,有些教程只有域名生成,没有 IP 生成,有些甚至报错 ...

  9. SQL 语句 增删改查、边学习边增加中..... 这一部分为select

    SQL语句按照最大的类别分为 1.增加 insert 2.删除 delete  https://www.cnblogs.com/kuangmeng/p/17756654.html 3.修改update ...

  10. [CISCN 2019华东南]Web11

    看到下面connection 里面的内容有一点像抓包出来的 就抓包试试 似乎感觉也没有什么用 看到这个东西,那么就想到改IP 添加X-Forwarded-For:127.0.0.1 发现这个IP随着我 ...