链接: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的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  3. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  4. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  5. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  7. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  8. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  9. Codeforces Beta Round #72 (Div. 2 Only)

    Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...

  10. Codeforces Beta Round #70 (Div. 2)

    Codeforces Beta Round #70 (Div. 2) http://codeforces.com/contest/78 A #include<bits/stdc++.h> ...

随机推荐

  1. Linux命令实战(三)

    1.file检查并显示文件类型(determine file type) 一般用法就是file 后面接要查看的文件 可以一个或多个 [root@test test]# ll total 140 -rw ...

  2. 【R语言学习笔记】 Day1 CART 逻辑回归、分类树以及随机森林的应用及对比

    1. 目的:根据人口普查数据来预测收入(预测每个个体年收入是否超过$50,000) 2. 数据来源:1994年美国人口普查数据,数据中共含31978个观测值,每个观测值代表一个个体 3. 变量介绍: ...

  3. PHP Laravel-包含你自己的帮助函数

    你可能想创建一个在应用的任何地方都可以访问的函数,这个教程将帮你实现

  4. Spring-boot构建多模块依赖工程时,maven打包异常:程序包xxx不存在

    在qizhi项目改版的时候, 所有代码都迁移好了, 但是compile的时候报程序包*****不存在, 具体到某一个类就是: 找不到符号. 下面这篇文章是正解 http://hbxflihua.ite ...

  5. __FILE__ basename() 作用

    __FILE__  basename() 作用 __FILE__ 获取当前文件或文件夹的绝对路径 basename(__FILE__) 获取当前文件或文件夹的名称 basename(__FILE__, ...

  6. 在开发框架中扩展微软企业库,支持使用ODP.NET(Oracle.ManagedDataAccess.dll)访问Oracle数据库

    在前面随笔<在代码生成工具Database2Sharp中使用ODP.NET(Oracle.ManagedDataAccess.dll)访问Oracle数据库,实现免安装Oracle客户端,兼容3 ...

  7. 前端 vue单页面应用刷新网页后vuex的state数据丢失的解决方案(转载)

    最近接手了一个项目,前端后端都要做,之前一直在做服务端的语言.框架和环境,前端啥都不会啊. 突然需要前端编程,两天速成了JS和VUE框架,可惜还是个半吊子.然后遇到了一个困扰了一整天的问题.一直调试都 ...

  8. 【dp】 AreYouBusy

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3535 题意: 多组背包, 0类型为为至少去1样, 1为至多取1样, 2 为随意. 如果将2类型 再添加 ...

  9. 移动端自动化测试Appium环境搭建(part1-2-3)

    Appium移动端自动化测试相信大家都不陌生,appium的铁哥们是selenium,不管是selenium还是appium,都是调用webdriver来做自动化测试.今天关于appium的介绍我们不 ...

  10. .Net Core 使用NPOI导入数据

    一.搭建环境 1.新建ASP.NET Core Web 应用程序 2.选择API 3.引用Swashbuckle.AspNetCore NuGet 包进行安装. Swashbuckle.AspNetC ...