SMU Summer 2023 Contest Round 14

A. Potion-making

就是解一个\(\frac{i}{i + j} = \frac{k}{100}\)方程,然后循环暴力找出答案

#include<bits/stdc++.h>

using i64 = long long;

using namespace std;

typedef pair<i64, i64> PII;

void solve(){
int k;
cin >> k; for(int i = 1;i <= 100;i ++){
for(int j = 0;j < 100;j ++){
if(i * 100 == k * (i + j)){
cout << i + j << '\n';
return ;
}
}
}
} int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); int T;
cin >> T;
while(T--){
solve();
} return 0;
}

B. Permutation Sort

其实就是特判首尾的情况

#include<bits/stdc++.h>

using i64 = long long;

using namespace std;

typedef pair<i64, i64> PII;

void solve(){
int n;
cin >> n;
vector<int> a(n);
for(auto &i : a) cin >> i; vector<int> b(n);
iota(b.begin(), b.end(),1); if(a == b){
cout << 0 << '\n';
return ;
}else {
if(a[0] == 1 || a.back() == n)
cout << 1 << '\n';
else if(a[0] == n && a.back() == 1)
cout << 3 << '\n';
else cout << 2 << '\n';
}
} int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); int T;
cin >> T;
while(T--){
solve();
} return 0;
}

D. Armchairs

\(dp[i][j]\)表示前\(j\)个椅子放\(i\)个人的最短时间

当前座位为空时,可以放人也可以不放人.

否则,为前一个座位放\(i\)个人的最短时间

#include<bits/stdc++.h>

using i64 = long long;

using namespace std;

typedef pair<i64, i64> PII;

int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); int n;
cin >> n;
vector<int> a(n + 1),b(1);
for(int i = 1;i <= n;i ++){
cin >> a[i];
if(a[i] == 1)
b.push_back(i);
} vector dp(n + 1, vector<int> (n + 1, 0x3f3f3f3f)); for(int i = 0;i <= n;i ++) dp[0][i] = 0; for(int i = 1;i < b.size();i ++){
for(int j = 1;j <= n;j ++){
if(a[j] == 0){
dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + abs(b[i] - j));
}else
dp[i][j] = dp[i][j - 1];
}
} cout << dp[b.size() - 1][n] << '\n';
return 0;
}

SMU Summer 2023 Contest Round 14的更多相关文章

  1. Codeforces Beta Round #14 (Div. 2)

    Codeforces Beta Round #14 (Div. 2) http://codeforces.com/contest/14 A 找最大最小的行列值即可 #include<bits/s ...

  2. BestCoder Round #14

    Harry And Physical Teacher Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Ja ...

  3. hdu 5066 Harry And Physical Teacher(Bestcoder Round #14)

    Harry And Physical Teacher Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Ja ...

  4. Codeforces Beta Round #14 (Div. 2) D. Two Paths 树形dp

    D. Two Paths 题目连接: http://codeforces.com/contest/14/problem/D Description As you know, Bob's brother ...

  5. Codeforces Beta Round #14 (Div. 2) C. Four Segments 水题

    C. Four Segments 题目连接: http://codeforces.com/contest/14/problem/C Description Several months later A ...

  6. Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题

    B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...

  7. Codeforces Beta Round #14 (Div. 2) A. Letter 水题

    A. Letter 题目连接: http://www.codeforces.com/contest/14/problem/A Description A boy Bob likes to draw. ...

  8. Codeforces Beta Round #14 (Div. 2) D. Two Paths 树的直径

    题目链接: http://codeforces.com/contest/14/problem/D D. Two Paths time limit per test2 secondsmemory lim ...

  9. Codeforces Round #14 D. Two Paths(求树上两条不相交的路径的乘积最大值)

    题目链接:  http://codeforces.com/problemset/problem/14/D 思路:直接枚举每一天路径的两端,然后求以每一端为树根的树上最长路径,然后相乘就可以了. # ...

  10. 2014 Benelux Algorithm Programming Contest (BAPC 14)E

    题目链接:https://vjudge.net/contest/187496#problem/E E Excellent Engineers You are working for an agency ...

随机推荐

  1. Unity网络通信系统设计

    Unity网络通信系统设计 Buffer报文 BufferEntity类作为报文基类的作用包括: 封装数据:BufferEntity类可以用来封装网络通信中的数据,方便在网络传输中进行处理和管理. 提 ...

  2. C# 13(.Net 9) 中的新特性 - 扩展类型

    C# 13 即 .Net 9 按照计划会在2024年11月发布,目前一些新特性已经定型,今天让我们来预览一个比较大型比较重要的新特性: 扩展类型 Extension types 在5月份的微软 Bui ...

  3. ClickHouse介绍(一)初次使用

    ClickHouse使用 ClickHouse是一个面向列存储的OLAP分析数据库,以其强大的分析速度而闻名.有关ClickHouse的介绍可以参考其官网说明[1].本文主要介绍它的基本使用. 1. ...

  4. 基于 SQLite 3 的 C 学习:2-高级操作

    基于 SQLite 3 的 C/C++ 学习:2-高级操作与有关函数 背景 基于 SQLite 3 的 C/C++ 学习:开发流程 与 基本函数 中,我们简单介绍了有关 SQLite3 函数的使用. ...

  5. 一文带你深入理解SpringMVC的执行原理

    今天大致来看一下Spring MVC的执行流程是什么样的 执行流程:也就是一个请求是怎么到我们Controller的,返回值是怎么给客户端的 本文分析的问题: 文件上传的请求是怎么处理的 跨域是怎么处 ...

  6. 【资料分享】全志科技T507工业核心板硬件说明书(上)

    目    录 前言 1硬件资源 1.1CPU 1.2ROM 1.3RAM 1.4时钟系统 1.5电源 1.6LED 1.7外设资源 2引脚说明 2.1引脚排列 2.2引脚定义 2.3内部引脚使用说明 ...

  7. vue - ElementUI

    关于ElementUI最好还是通过实践项目来做,来熟悉. 这只是一些ElementUI的注意事项,至此vue2的内容真的全部完结,后面将继续vue3的内容更新. 一.完整引入 一般提及什么什么UI会有 ...

  8. python3 webssh

    简介 webssh 是 一个简单的 Web 应用程序,用作 ssh 客户端来连接到 ssh 服务器.它是用Python编写的,基于tornado.paramiko和xterm.js.下面简单搭建一个网 ...

  9. Java获取客户端请求信息

    客户端工具类 /** * 客户端工具类 * * @author hviger */ public class ServletUtils { /** * 获取String参数 */ public sta ...

  10. DDP:微软提出动态detection head选择,适配计算资源有限场景 | CVPR 2022

    DPP能够对目标检测proposal进行非统一处理,根据proposal选择不同复杂度的算子,加速整体推理过程.从实验结果来看,效果非常不错 来源:晓飞的算法工程笔记 公众号 论文: Should A ...