Codeforces Round #519 by Botan Investments
Codeforces Round #519 by Botan Investments
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define lson i<<1
#define rson i<<1|1
#define LS l,mid,lson
#define RS mid+1,r,rson
#define mem(a,x) memset(a,x,sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define ll long long
#define ull unsigned long long
#define lowbit(x) (x&-x)
#define pb(x) push_back(x)
#define enld endl
#define mian main
#define itn int
#define prinft printf
#define Max(a,b,c) max(a,max(b,c))
#pragma GCC optimize(2)
//#pragma comment(linker, "/STACK:102400000,102400000")
const double PI = acos (-1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
;
;
;
;
;
using namespace std;
;
int temp;
;
int main() {
//std::ios::sync_with_stdio(false);
//cin.tie(NULL);
;
while(cin>>n) {
sum=;
;i<=n;++i) {
cin>>temp;
sum+=temp;
maxn=max(temp,maxn);
}
for(int k=maxn;;++k) {
if(k*n-sum>sum) {
cout<<k<<endl;
break;
}
}
}
}
A - Elections
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define lson i<<1
#define rson i<<1|1
#define LS l,mid,lson
#define RS mid+1,r,rson
#define mem(a,x) memset(a,x,sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define ll long long
#define ull unsigned long long
#define lowbit(x) (x&-x)
#define pb(x) push_back(x)
#define enld endl
#define mian main
#define itn int
#define prinft printf
#define Max(a,b,c) max(a,max(b,c))
#pragma GCC optimize(2)
//#pragma comment(linker, "/STACK:102400000,102400000")
const double PI = acos (-1.0);
const int INF = 0x3f3f3f3f;
;
;
;
;
;
using namespace std;
int n;
int a[MAXN];
int ans[MAXN];
bool check(int x)
{
;i+x<n;++i) {
]-a[i]!=a[i+x+]-a[i+x]) return false;
}
return true;
}
int main() {
//std::ios::sync_with_stdio(false);
//cin.tie(NULL);
cin>>n;
;i<=n;++i) cin>>a[i];
;
a[]=;
;i<=n;++i) {
if(check(i)) ans[cnt++]=i;
}
cout<<cnt<<endl;
;i<cnt;++i ) {
if(i) cout<<' ';
cout<<ans[i];
}cout<<endl;
}
B - Lost Array
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define lson i<<1
#define rson i<<1|1
#define LS l,mid,lson
#define RS mid+1,r,rson
#define mem(a,x) memset(a,x,sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define ll long long
#define ull unsigned long long
#define lowbit(x) (x&-x)
#define pb(x) push_back(x)
#define enld endl
#define mian main
#define itn int
#define prinft printf
#define Max(a,b,c) max(a,max(b,c))
#pragma GCC optimize(2)
//#pragma comment(linker, "/STACK:102400000,102400000")
const double PI = acos (-1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
;
;
;
;
;
using namespace std;
string s;
int a[MAXN];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cin>>s;
) {cout<<<<endl; ;}
mem(a,);
;i<s.size()-;++i) {
if(i)cout<<' ';
]) cout<<;
;
}
]=="<<endl;
"<<endl;
}
C - Smallest Word
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define lson i<<1
#define rson i<<1|1
#define LS l,mid,lson
#define RS mid+1,r,rson
#define mem(a,x) memset(a,x,sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define ll long long
#define ull unsigned long long
#define lowbit(x) (x&-x)
#define pb(x) push_back(x)
#define enld endl
#define mian main
#define itn int
#define prinft printf
#define Max(a,b,c) max(a,max(b,c))
#pragma GCC optimize(2)
//#pragma comment(linker, "/STACK:102400000,102400000")
const double PI = acos (-1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
;
;
;
;
;
using namespace std;
int n,m;
][MAXN];
][MAXN];
ll ans[MAXN];
ll q;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
mem(ans,);
; i<=m; ++i) {
; j<=n; ++j) {
cin>>a[i][j];
==)
pre[i][a[i][j]]=;
else
pre[i][a[i][j]]=a[i][j-];
}
}
q=n;
; i<=n; ++i) {
ll cnt=;
; j<m; ++j) {
if(pre[j][a[m][i]]==pre[m][a[m][i]])
cerr<<++cnt<<endl;
//++cnt;
}
)
ans[i]=ans[i-]+;
q+=ans[i];
}
cout<<q<<endl;
}
D - Mysterious Crime
Codeforces Round #519 by Botan Investments的更多相关文章
- Codeforces Round #519 by Botan Investments(前五题题解)
开个新号打打codeforces(以前那号玩废了),结果就遇到了这么难一套.touristD题用了map,被卡掉了(其实是对cf的评测机过分自信),G题没过, 700多行代码,码力惊人.关键是这次to ...
- Codeforces Round #519 by Botan Investments F. Make It One
https://codeforces.com/contest/1043/problem/F 题意 给你n个数,求一个最小集合,这个集合里面数的最大公因数等于1 1<=n<=3e5 1< ...
- Codeforces Round #519 by Botan Investments翻车记
A:枚举答案即可.注意答案最大可达201,因为这个wa了一发瞬间爆炸. #include<iostream> #include<cstdio> #include<cmat ...
- 【Codeforces Round #519 by Botan Investments E】Train Hard, Win Easy
[链接] 我是链接,点我呀:) [题意] [题解] 设每个人做第一题.第二题的分数分别为x,y 我们先假设没有仇视关系. 即每两个人都能进行一次训练. 那么 对于第i个人. 考虑第j个人对它的贡献 如 ...
- 【Codeforces Round #519 by Botan Investments A】 Elections
[链接] 我是链接,点我呀:) [题意] [题解] 枚举k 那么另外一个人的得票就是nk-sum(ai) 找到最小的满足nk-sum(ai)>sum(ai)的k就ok了 [代码] #includ ...
- 【 Codeforces Round #519 by Botan Investments B】Lost Array
[链接] 我是链接,点我呀:) [题意] [题解] 枚举k 不难根据a得到x[0..k-1] 然后再根据a[k+1..n]来验证一下得到的x是否正确就好. [代码] #include <bits ...
- 【Codeforces Round #519 by Botan Investments C】 Smallest Word
[链接] 我是链接,点我呀:) [题意] [题解] 模拟了一两下.. 然后发现. 对于每一个前缀. 组成的新的最小字典序的字符串 要么是s[i]+reverse(前i-1个字符经过操作形成的最大字典序 ...
- 【Codeforces Round #519 by Botan Investments D】Mysterious Crime
[链接] 我是链接,点我呀:) [题意] 相当于问你这m个数组的任意长度公共子串的个数 [题解] 枚举第1个数组以i为起点的子串. 假设i..j是以i开头的子串能匹配的最长的长度. (这个j可以给2. ...
- Codeforces Round #519 题解
A. Elections 题意概述 给出 \(a_1, \ldots, a_n\),求最小的 \(k (k \ge \max a_i)\), 使得 \(\sum_{i=1}^n a_i < \s ...
随机推荐
- navicat报caching_sha2_password异常
使用navicat连接mysql报错(升级到mysql8版本时的错) 解决办法: 通过命令行登录mysql后, 输入: alter user 'root'@'localhost' IDENTIFIED ...
- centos6.5环境disconf管理端安装配置详解
操作系统:centos6.5 x86_64 安装目录/data 1.安装nginx1.10.1 rpm -ivh http://nginx.org/packages/centos/6/noarch/R ...
- 企业内部在centos7.2系统中必杀技NTP时间服务器及内网服务器时间同步(windows和linux客户端同步)
网络时间协议NTP(Network Time Protocol)是用于互联网中时间同步的标准互联网协议.NTP的用途是把计算机的时间同步到某些时间标准.目前采用的时间标准是世界协调时UTC(Unive ...
- android margin--负的margin的使用
通常情况下,如果我们想要两个控件实现重叠的效果,一般都是使用FrameLayout 或者RelativeLayout布局.其实,如果设置两个控件的margin值为负数,也能实显控件重叠的效果. 先展示 ...
- php协程
多任务 (并行和并发) 在讲协程之前,先谈谈多进程.多线程.并行和并发. 对于单核处理器,多进程实现多任务的原理是让操作系统给一个任务每次分配一定的 CPU 时间片,然后中断.让下一个任务执行一定的时 ...
- python 全栈开发,Day12(函数的有用信息,带参数的装饰器,多个装饰器装饰一个函数)
函数的执行时,*打散.函数的定义时,*聚合. from functools import wraps def wrapper(f): # f = func1 @wraps(f) def inner(* ...
- jenkins X实践系列(1) —— 背景知识
本文介绍jenkins X(以下简称jx)相关的背景技术. jenkins X 简介 Jenkins X 是一个高度集成化的CI/CD平台,基于Jenkins和Kubernetes实现,旨在解决微服务 ...
- Evolution ZOJ2853
矩阵太大导致爆栈 解决方法:矩阵不要开在main函数里面 全部在外面处理 main函数只能处理简单的赋值和加减 损失的要自减!! 最后为 sum+=t[i]*ans.m[i][n-1]; 得 ...
- C++对文本文件的读取和输出
本文转载自xmh_free 自己浏览了上方的博客,主要整理了一下关于C++对文件的输入输出方法,如果想看C语言的输入输出方法,可浏览上述链接的博客 C++读写函数 在C++中,对文件的操作是通过str ...
- Ubuntu 下常用快捷键
参考链接:Ubuntu终端以及应用下快捷键大全https://linux.cn/article-3025-1.html 桌面常用快捷键 Alt + F1:聚焦到桌面左侧任务导航栏,可按上下键进行导航 ...