AtCoder Beginner Contest 315

A - tcdr (atcoder.jp)

一次遍历

#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); string s, ans = "";
cin >> s;
for (auto i : s) {
if (i != 'a' && i != 'e' && i != 'o' && i != 'u' && i != 'i')
ans += i; }
cout << ans << '\n';
return 0;
}

B - The Middle Day (atcoder.jp)

每次去比较每个月有没有到达一半的天数即可

#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 M;
cin >> M;
vector<int> D(M + 1);
int sum = 0;
for (int i = 1; i <= M; i ++) {
cin >> D[i];
sum += D[i];
} int now = 0;
sum = (sum + 1) / 2;
for(int i = 1;i<= M;i ++){
if(now + D[i] >= sum){
cout << i << ' ' << sum - now << '\n';
return 0;
}else
now += D[i];
} return 0;
}

C - Flavors (atcoder.jp)

分别与每个相同口味的美味程度比较以及与不同口味的最大的两个美味程度比较

#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<i64> F(N + 1), S(N + 1);
map<int, priority_queue<i64>> mp;
for (int i = 1; i <= N; i ++) {
cin >> F[i] >> S[i];
mp[F[i]].push(S[i]);
} priority_queue<int> Q;
i64 ans = 0;
for (auto [_, q] : mp) {
Q.push(q.top());
if (q.size() >= 2) {
i64 m1 = q.top();
q.pop();
i64 m2 = q.top();
ans = max(m1 + m2 / 2, ans);
}
} if (Q.size() > 1) {
i64 M1 = Q.top();
Q.pop();
i64 M2 = Q.top();
ans = max(M1 + M2, ans);
} cout << ans << '\n'; return 0;
}

E - Prerequisites (atcoder.jp)

直接去递归找每本书需要的前置书

#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<vector<int>> C(N + 1);
for (int i = 1; i <= N; i ++) {
int c;
cin >> c;
for (int j = 0; j < c; j ++) {
int x;
cin >> x;
C[i].push_back(x);
}
} vector<bool> read(N + 1); auto dfs = [&](auto self, int x) -> void{
if (read[x])
return ; for (auto i : C[x])
self(self, i); read[x] = true; if (x != 1)
cout << x << ' ';
}; dfs(dfs, 1);
return 0;
}

AtCoder Beginner Contest 315的更多相关文章

  1. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  2. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  3. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  4. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  5. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  6. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  7. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  8. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  9. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】

    AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...

  10. AtCoder Beginner Contest 075 C bridge【图论求桥】

    AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...

随机推荐

  1. Ajax分析与爬取实战

    Ajax 分析与爬取实战 准备工作 安装好 Python3 了解 Python HTTP 请求库 requests 的基本用法 了解 Ajax 基础知识和分析 Ajax 的基本方法 爬取目标 以一个示 ...

  2. zabbix---监控Oracle12c数据库

    使用插件:orabbix用于监控oracle实例的zabbix插件 orabbix插件下载地址:http://www.smartmarmot.com/product/orabbix/download/ ...

  3. 在Xcode编写我们的quick help

    程序环境 Xcode 13.2.1 "写代码要经常写注释."虽然很多人不以为然,但是在使用Xcode的时候,我们在写注释的时候稍微注意一下格式的话,Xcode会给我们带来额外的正反 ...

  4. mermaid语法画图

    mermaid 脚本语言 graph TB 从上到下 graph BT 从下到上 graph RL 从右到左 graph LR 从左到右 graph LR; A001-->B001; graph ...

  5. Java socket 获取gps定位

    1.Java socket 获取gps定位的方法 在Java中使用Socket来直接获取GPS定位信息并不直接可行,因为GPS数据通常不是通过Socket通信来获取的.GPS数据通常由设备(如智能手机 ...

  6. 最近很火的Vue Vine是如何实现一个文件中写多个组件

    前言 在今年的Vue Conf 2024大会上,沈青川大佬(维护Vue/Vite 中文文档)在会上介绍了他的新项目Vue Vine.Vue Vine提供了全新Vue组件书写方式,主要的卖点是可以在一个 ...

  7. yolov5+deepsort+slowfast复现

    1.运行环境 ubuntu 18.04.1 Cuda 11.5 Python 3.8.15 torch 1.10.1+cu113 torchvision 0.11.2+cu113 2.安装PyTorc ...

  8. 解决方案 | vbnet的msgbox 窗口最前置,topmost属性设置

    For that you can use the TopMost Property of MsgBox (Number 262144) MsgBox("Hello there", ...

  9. SpringBoot实战:轻松实现接口数据脱敏

    引言 在现代的互联网应用中,数据安全和隐私保护变得越来越重要.尤其是在接口返回数据时,如何有效地对敏感数据进行脱敏处理,是每个开发者都需要关注的问题.本文将通过一个简单的Spring Boot项目,介 ...

  10. 重写Save()的两种方法

    # 重新Save()def save(self, force_insert=False, force_update=False, using=None, update_fields=None): su ...