AtCoder Beginner Contest 338(A~E补题)
A
签到
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
using namespace std;
const int N=5e5+10;
void solve()
{
string str;cin>>str;
bool st=true;
rep(i,0,str.size()-1)
{
if(!i)
{
if(str[i]>='A'&&str[i]<='Z') continue;
else
{
cout<<"No"<<endl;
return;
}
}
if(str[i]>='a'&&str[i]<='z') continue;
else
{
cout<<"No"<<endl;
return;
}
}
cout<<"Yes"<<endl;
}
int main()
{
IOS
// freopen("1.in", "r", stdin);
int t;
// cin>>t;
// while(t--)
solve();
return 0;
}
B
签到题
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
using namespace std;
const int N=5e5+10;
void solve()
{
string str;cin>>str;
map<char,int>cnt;
for(auto c:str) cnt[c]++;
char c;
int k=0;
for(auto it:cnt)
{
if(it.y>k)
{
k=it.y;
c=it.x;
}
}
cout<<c<<endl;
}
int main()
{
IOS
// freopen("1.in", "r", stdin);
int t;
// cin>>t;
// while(t--)
solve();
return 0;
}
C题
观察到数据范围n只有10,想到去枚举a的数量然后去看b最多能做多少。
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
using namespace std;
const int N=20;
int c[N],a[N],b[N],n;
bool check1(int x)
{
rep(i,1,n) if(x*a[i]>c[i]) return false;
return true;
}
void solve()
{
cin>>n;
int sa=0,sb=0,sc=0;
rep(i,1,n) cin>>c[i],sc+=c[i];
rep(i,1,n) cin>>a[i],sa+=a[i];
rep(i,1,n) cin>>b[i],sb+=b[i];
int ans=0;
rep(gg,0,1e6)
{
if(!check1(gg)) break;
int kk=1e6;
rep(i,1,n)
{
if(b[i]==0) continue;
int xx=c[i]-a[i]*gg;
xx/=b[i];
kk=min(kk,xx);
}
ans=max(ans,gg+kk);
}
cout<<ans<<endl;
}
int main()
{
IOS
// freopen("1.in", "r", stdin);
// int t;
// cin>>t;
// while(t--)
solve();
return 0;
}
D题
也很巧妙,贡献法的思想。
对于每一个路径计算他对不同断桥产生的贡献。
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
using namespace std;
const int N=1e6+10;
ll n,m,x[N],cf[N];
ll dist(ll x,ll y)
{
if(x<=y) return y-x;
else return n-(x-y);
}
void add(ll x,ll y,ll d)
{
if(x<=y)
{
cf[x]+=d;
cf[y]-=d;
}
else
{
cf[x]+=d;
cf[n+1]-=d;
cf[1]+=d;
cf[y]-=d;
}
}
void solve()
{
cin>>n>>m;
rep(i,1,m) cin>>x[i];
rep(i,1,m-1)
{
add(x[i],x[i+1],dist(x[i+1],x[i]));
add(x[i+1],x[i],dist(x[i],x[i+1]));
}
ll ans=1e18;
rep(i,1,n) cf[i]+=cf[i-1];
rep(i,1,n) ans=min(ans,cf[i]);
cout<<ans<<endl;
}
int main()
{
IOS
// freopen("1.in", "r", stdin);
int t;
// cin>>t;
// while(t--)
solve();
return 0;
}
E题
#include <bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
#define pb push_back
using namespace std;
const int N=4e5+10;
int cf[N],x[N],y[N];
void solve()
{
int n;cin>>n;
rep(i,1,n)
{
cin>>x[i]>>y[i];
if(x[i]>y[i]) swap(x[i],y[i]);
cf[x[i]]+=1;cf[y[i]+1]-=1;
}
rep(i,1,2*n) cf[i]+=cf[i-1];
rep(i,1,n)
{
if(cf[x[i]]!=cf[y[i]])
{
cout<<"Yes"<<endl;
return;
}
}
cout<<"No"<<endl;
}
signed main()
{
IOS
// freopen("1.in", "r", stdin);
// int _;
// cin>>_;
// while(_--)
solve();
return 0;
}
AtCoder Beginner Contest 338(A~E补题)的更多相关文章
- AtCoder Beginner Contest 188 F - +1-1x2 思维题
题目描述 给你两个数 \(x\),\(y\) 可以对 \(x\) 进行 \(+1,-1\) 或 \(\times 2\) 的操作 问最少操作多少次后变为 \(y\) \(x,y \leq 10^{18 ...
- AtCoder Beginner Contest 137 F
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...
- AtCoder Beginner Contest 068 ABCD题
A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 223
AtCoder Beginner Contest 223 A是纯纯的水题,就不说了 B - String Shifting 思路分析 我真的sb,一开始想了好久是不是和全排列有关,然后读了好几遍题目也 ...
- AtCoder Beginner Contest 064 D - Insertion
AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...
- AtCoder Beginner Contest 075 C bridge【图论求桥】
AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...
- AtCoder Beginner Contest 224
AtCoder Beginner Contest 224 A - Tires 思路分析: 判断最后一个字符即可. 代码如下: #include <bits/stdc++.h> using ...
- KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) 题解
KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) 题解 哦淦我已经菜到被ABC吊打了. A - Century 首先把当前年 ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
随机推荐
- P9110 [PA2020] Samochody dostawcze
题目简述 有 \(n\) 个点,这些点分为两种类型.第一种,点在 \((x,0)\) 的位置.这些点从 \(t_i\) 的时刻开始向北走.第二种,点在 \((0,y)\) 的位置.这些点从 \(t_i ...
- 从零开始配置vim(32)——最后再说两句
很抱歉我决定结束这个系列的内容了.原本我打算介绍markdown.orgmode相关的配置,甚至还打算介绍如何在vim 中使用 emacs 的 org-agenda 来进行日常的任务管理.但是出于一些 ...
- vim 从嫌弃到依赖(21)——跨文件搜索
之前介绍了vim中的搜索模式,使用正则表达式可以很方便的在一个文件中进行搜索.后续也介绍了如何使用 argsdo 命令在参数列表中进行替换操作.但是到目前为止还没有介绍如何在工程目录中进行搜索,而这个 ...
- 4.5 C++ Boost 文件目录操作库
Boost 库是一个由C/C++语言的开发者创建并更新维护的开源类库,其提供了许多功能强大的程序库和工具,用于开发高质量.可移植.高效的C应用程序.Boost库可以作为标准C库的后备,通常被称为准标准 ...
- GD库常用实例
GD库常用实例 一.图片水印 1.实现步骤 打开原图(也叫操作的目标图片) 打开水印图(也叫水印来源图片) 使用 imagecopymerge 将小图合并至大图的指定位置 输出图片 销毁资源 2. ...
- Markdown Rules 详解
使用VSCode编写Markdown文件时,建议安装插件markdownlint,它可以帮助自己更加规范的写文章. 下面是所有的markdown语法错误信息以便纠错. Rules文档 Markdown ...
- Java并发(八)----使用线程避免cpu占用100%
1.sleep 实现 在没有利用 cpu 来计算时,不要让 while(true) 空转浪费 cpu,这时可以使用 yield 或 sleep 来让出 cpu 的使用权给其他程序 while(true ...
- yapi tag的问题,暂时只保留一个tag
yapi 的tag是需要先在网页上建立好,如:
- MySQL的CTE(公用表表达式)
(一)概念 MySQL的CTE是在MySQL8.0版本开始支持的,公用表表达式是一个命名的临时结果集,仅在单个SQL语句(例如select.insert.delete和update)的执行范围内存在. ...
- LLM研究之-NVIDIA的CUDA
一.什么是NVIDIA的CUDA CUDA(Compute Unified Device Architecture)是由NVIDIA公司开发的一个并行计算平台和应用程序编程接口(API),它允许软件开 ...