CodeForces-508A~D篇 div.2
链接:https://codeforc.es/contest/1038
A题:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define PI acos(-1.0)
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;
map<int,int> mp;
int a[];
int main()
{
ios::sync_with_stdio(false);
int n,k;
string s;
cin>>n>>k;
cin >> s;
int len = ;
int ans = INF;
for(int i=;i<n;i++) a[i] = s[i] - 'A',mp[a[i]]++;
for (int i = ; i < k; i++) ans = min(ans, mp[i]);
cout << ans * k << endl; return ;
}
B题:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define PI acos(-1.0)
typedef pair<int,int> P;
const int maxn=0x3f3f3f3f; int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n;
if(n<=) cout<<"No"<<endl;
else
{
cout<<"Yes"<<endl;
cout<<n-(n+>>);
for(int i=;i<=n;i+=) cout<<" "<<i;
cout<<endl;
cout<<(n+>>);
for(int i=;i<=n;i+=) cout<<" "<<i;
cout<<endl; }
return ;
}
C题:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define PI acos(-1.0)
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;
const int maxn=1e6+;
int n;
LL a[maxn],b[maxn],sum1,sum2;
int main()
{
ios::sync_with_stdio(false);
cin>>n;
sum1=sum2=;
for(int i=;i<=n;i++) cin>>a[i];
for(int i=;i<=n;i++) cin>>b[i];
sort(a+,a++n); sort(b+,b++n);
//for(int i=1;i<=n;i++) cout<<a[i]<<" "<<b[i]<<endl;
int flag1=n,flag2=n;
while()
{
if(a[flag1]<=b[flag2]) flag2--;
else sum1+=a[flag1],flag1--;
if(flag2==)
{
sum1+=a[flag1];
break;
}
else if(flag1==)
{
sum2+=b[flag2];
break;
}
if(b[flag2]<=a[flag1]) flag1--;
else sum2+=b[flag2],flag2--;
if(flag2==)
{
sum1+=a[flag1];
break;
}
else if(flag1==)
{
sum2+=b[flag2];
break;
}
}
cout<<sum1-sum2<<endl;
return ;
}
D题:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define PI acos(-1.0)
typedef pair<int,int> P;
const int maxn=5e5+;
int n;
LL a[maxn];
int main()
{
ios::sync_with_stdio(false); cin>>n;
for(int i=;i<=n;i++) cin>>a[i];
if(n==) cout<<a[]<<endl;
else
{
sort(a+,a++n);
LL ans=;
ans=abs(a[]-a[n]);
for(int i=;i<n;i++) ans=ans+abs(a[i]);
cout<<ans<<endl;
} return ;
}
CodeForces-508A~D篇 div.2的更多相关文章
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
- Codeforces Beta Round #72 (Div. 2 Only)
Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...
- Codeforces Beta Round #70 (Div. 2)
Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...
随机推荐
- 微信小程序(mpvue) wx.openSetting 无法调起设置页面
在开发过程有个需要保存图片/视频到设备相册的业务,so easy~ 巴啦啦撸下来了完整功能, wx.saveVideoToPhotosAlbum 会自动调起用户授权,美滋滋~~ btu.... ...
- gitbook的插件配置
原生的gitbook样式比较单一,美观度和功能欠佳,可通过相关插件进行拓展. 插件地址:https://plugins.gitbook.com/ 主目录下新建book.json: { "au ...
- 微擎JS资源请求 403
微擎JS资源请求 403 1.确认JS是否指定 type ==> text/javascript 2.确认src的路径是否正确,{MODULE_URL}项目的根目录带反斜杠 3.实例:(PS:t ...
- Python3.7.1学习(二)使用schedule模块定时执行任务
python中有一个轻量级的定时任务调度的库:schedule.他可以完成每分钟,每小时,每天,周几,特定日期的定时任务.因此十分方便我们执行一些轻量级的定时任务. 1 安装 1.1在cmd中输入p ...
- Spring boot 加入shiro支持
在项目添加依赖 <!-- shiro spring. --> <dependency> <groupId>org.apache.shiro</groupId& ...
- Ubuntu 16.04 安装Maven3.3.9
1 下载地址 http://maven.apache.org/download.cgi 2 将下载到的apache-maven-3.3.9-bin.tar.gz文件上传到/temp目录下,然后切换到r ...
- 从壹开始 [ Design Pattern ] 之二 ║ 单例模式 与 Singleton
前言 这一篇来源我的公众号,如果你没看过,正好直接看看,如果看过了也可以再看看,我稍微修改了一些内容,今天讲解的内容如下: 一.什么是单例模式 [单例模式],英文名称:Singleton Patter ...
- javescript 的 对象
一,定义:对象是JavaScript的一个基本数据类型,是一种复合值,它将很多值(原始值或者其他对象)聚合在一起,可通过名字(name/作为属性名)访问这些值.即属性的无序集合. 关键是name属性名 ...
- vue中动态加载img
想实现动态加载图片,当点击“首页”时,图片变色 代码如下: <mt-tabbar v-model="selected" fixed class="border-1p ...
- Java基础知识总结之垃圾回收机制
垃圾回收机制 Java垃圾回收机制是Java语言的重要功能之一.当程序创建对象,数组等引用类型对象时,系统会自动在内存区为之分配一块内存,对象就保存在这块内存区内,当这块内存不再被任何变量引用时,这块 ...