链接: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. ASP.NET Core 1.0: Using Entity Framework Core

    伴随着ASP.NET Core 1.0发布的还有Entity Framework Core 1.0; 官方文档链接:https://docs.efproject.net/en/latest/platf ...

  2. Material for oauth 2

    oauth 2 in 8 steps:  https://knpuniversity.com/screencast/oauth Live demo of oauth 2 (with server im ...

  3. PHP 当Swoole 遇上 ThinkPHP5

    本文假设你已经有了 Linux 操作系统的 PHP 环境,强烈推荐使用 Vagrant 来搭建开发环境 安装 Swoole PECL 拓展可以通过 pecl 命令或者通过源码包编译安装,本文采用 pe ...

  4. 02. JVM运行机制

    JVM运行机制 JVM启动流程 JVM基本结构 内存模型 编译和解释运行的概念 一.JVM启动流程

  5. 张孝祥java高新技术 --- jkd1.5 新特性 -- 精华总结

    1. 抽象方法的使用 如果一个方法中大量出现if语句, 那么, 就应该考虑使用抽象来处理. 如下例: package com.lxl; public class Weekend { //周日 publ ...

  6. HTTP 协议漫谈

    转载出处:HTTP 协议漫谈 简介 网络上已经有不少介绍 HTTP 的好文章,对HTTP的一些细节介绍的比较好,所以本篇文章不会对 HTTP 的细节进行深究,而是从够高和更结构化的角度将 HTTP 协 ...

  7. SSM框架整合 详细步骤(备注) 附源码

    整合思路 将工程的三层结构中的JavaBean分别使用Spring容器(通过XML方式)进行管理. 整合持久层mapper,包括数据源.会话工程及mapper代理对象的整合: 整合业务层Service ...

  8. python接口设计中的__all__和del

    最近在实现python接口中遇到了一些小问题,解决后总结如下. 目的:在设计接口时,只暴露某个文件的特定方法. 例如: t.py import os import sys def a(): pass ...

  9. IIS部署.net core网站

    1 安装   Windows8.1-KB2999226-x64 2 安装 DotNetCore.1.0.4_1.1.1-WindowsHosting http://download.microsoft ...

  10. SpringBoot实现登录

    1.使用Spring Initializer快速创建Spring Boot项目 1.1 IDEA:使用 Spring Initializer快速创建项目 IDE都支持使用Spring的项目创建向导快速 ...