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> ...
随机推荐
- Unity 简记(2)--2D移动
目录 1.输入 1.1直接检测按下哪个按键 1.2.检测水平输入和垂直输入 2.移动 2.1.Transform组件 2.2.RigidBody组件 2.3.NavMeshAgent组件 2.4.Ch ...
- 【自然语言处理】利用LDA对希拉里邮件进行主题分析
首先是读取数据集,并将csv中ExtractedBodyText为空的给去除掉 import pandas as pd import re import os dir_path=os.path.dir ...
- [ASP.NET Core 3框架揭秘] 文件系统[1]:抽象的“文件系统”
ASP.NET Core应用 具有很多读取文件的场景,比如配置文件.静态Web资源文件(比如CSS.JavaScript和图片文件等)以及MVC应用的View文件,甚至是直接编译到程序集中的内嵌资源文 ...
- nyoj 484-The Famous Clock
484-The Famous Clock 内存限制:64MB 时间限制:1000ms 特判: No 通过数:2 提交数:2 难度:1 题目描述: Mr. B, Mr. G and Mr. M are ...
- C语言|博客作业06
这个作业属于哪个课程 C语言程序设计II 这个作业的要求在哪里 https://edu.cnblogs.com/campus/zswxy/CST2019-1/homework/9885 我在这个课程的 ...
- usaco training <1.2 Your Ride Is Here>
题面 Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often ...
- 【并发编程】Java对并发编程的支持历史
本博客系列是学习并发编程过程中的记录总结.由于文章比较多,写的时间也比较散,所以我整理了个目录贴(传送门),方便查阅. 并发编程系列博客传送门 本文转载,原文请点击链接 本章主要对Java并发(Con ...
- 新闻实时分析系统 Spark Streaming实时数据分析
1.Spark Streaming功能介绍1)定义Spark Streaming is an extension of the core Spark API that enables scalable ...
- 【集训Day1 测试】选择课题
选择课题(bestproject) [问题描述] Robin 要在下个月交给老师 n 篇论文,论文的内容可以从 m 个课题中选择.由于课题数有限,Robin 不得不重复选择一些课题.完成不同课题的论文 ...
- 迈进java初中级程序员分水岭是否合格?十个题告诉你!
前言 不论你是职场新人还是步入职场N年的职场新人大哥大~当然这个N<3~,我能担保你答不对这十个题~不要问我为什么这么自信~,这些个题还是"有水平"的javase的基础题,传 ...