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 ...
随机推荐
- 从零开始配置 vim(3)—— 键盘映射进阶
严格意义上来说,快捷键的绑定应该是键盘映射,将某些键映射为另一些键. 在上篇我们介绍了基本的键盘映射操作,知道了如何 :map.:imap.:vmap.:nmap这些命令来映射键盘快捷键.它们很方便, ...
- 【二】最新多智能体强化学习文章如何查阅{顶会:AAAI、 ICML }
相关文章: [一]最新多智能体强化学习方法[总结] [二]最新多智能体强化学习文章如何查阅{顶会:AAAI. ICML } [三]多智能体强化学习(MARL)近年研究概览 {Analysis of e ...
- webpack重新打包清空dist文件夹的问题
1.5.20.0以上版本才支持output属性里的clean:true 5.20.0+ 5.20以下版本清除dist文件内容一般使用插件 clean-webpack-plugin, 5.20版本以后o ...
- XD刷机报错bad CRC
测试需要,给一台1/4 rack的X8M HC刷机,使用oeda配置好的xml文件,执行命令列出本次刷机的所有步骤: [root@dbm11dbadm01 linux-x64]# ./install. ...
- .NET Core开发实战(第29课:定义仓储:使用EF Core实现仓储层)--学习笔记
29 | 定义仓储:使用EF Core实现仓储层 首先定义仓储层的接口,以及仓储层实现的基类,抽象类 仓储层的接口 namespace GeekTime.Infrastructure.Core { / ...
- Linux-如何比较比较两个目录中的文件差异
在 Linux 命令行中比较两个目录是一项常见的任务,特别是当你需要确保两个目录之间的文件完全相同时. 本文我们将介绍一些在 Linux 命令行中比较两个目录的方法. 方法一:使用 diff 命令比较 ...
- NC23803 DongDong认亲戚
题目链接 题目 题目描述 DongDong每年过春节都要回到老家探亲,然而DongDong记性并不好,没法想起谁是谁的亲戚(定义:若A和B是亲戚,B和C是亲戚,那么A和C也是亲戚),她只好求助于会编程 ...
- SSD 表项管理概述(一)——L1、L2、L3
分类 名称 说明 映射表相关 L1 Table 记录每个4KB用户数据在SSD上的存放物理地址: L2 Table 记录每个sub L1 Table在SSD上的存放物理地址: L3 Table 记录每 ...
- Shell 特殊符号(变量)用法小结
Shell | 特殊变量 $n 基本语法: $n (功能描述:n 为数字,$0 代表该脚本名称,$1-$9 代表第一到第九个参数,十以上的参数,十以上的参数需要用大括号包含,如${10}) 例如: ...
- 【Unity3D】Unity与Android交互
1 前言 本文主要介绍 Unity 打包发布 Android apk 流程.基于 AndroidJavaObject(或 AndroidJavaClass)实现 Unity 调用 Java 代码. ...