链接: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. 201871010114-李岩松《面向对象程序设计(java)》第四周学习总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...

  2. 《计算机网络 自顶向下方法》 第2章 应用层 Part2

    域名.主机名?   从范围上看: 域名的范围比主机名大 一个域名下通常有多个主机名 从组成上看: 主机名 = 服务器名(或计算机名) + 域名 举例说明: baidu.com 是百度的域名 www.b ...

  3. [LC]21题 Merge Two Sorted Lists (合并两个有序链表)(链表)

    ①英文题目 Merge two sorted linked lists and return it as a new list. The new list should be made by spli ...

  4. 初识JSP:JSP的注释、脚本、声明、表达式

    1.JSP的注释 在HTML当中,如果使用传统的注释我们可以在客户端,也就是网页上右键查看源代码里面看得到该注释,但是JSP注释无法在客户端里看到.源码里面会只会看到JSP注释的地方空出来. 使用方法 ...

  5. Comet OJ - Contest #10 C题 鱼跃龙门

    ###题目链接### 题目大意: 给你一个 x ,让你求出最小的正整数 n 使得 n * (n + 1) / 2  % x == 0 ,即 n * (n + 1)  % 2x == 0 . 分析: 1 ...

  6. SQL Server 2014:在修改表的内容时,提示“此单元格已更改,尚未将更改提交到数据库”,怎么处理?

    那一行上的属性为“不允许为null”的所有字段都填上对应信息,按回车键或者点击下一行任意一个单元格便会自动将更改的信息提交到数据库.

  7. Mysql 开启远程连接服务

    Mysql 开启远程连接服务 修改要远程访问的那个用户的 host 为 % use mysql; insert into user (host, user, password) values('%', ...

  8. 有趣的css3实战案例剖析——(水纹波动)

    对于css3的学习,更多的是在于对新特性和基础理论的熟悉, 这篇文章通过一个案例带领大家了解css3里一些理论知识,也将一些技巧加以总结,从而提高大家的开发效率: 本次案例为(水纹波动),不用js写动 ...

  9. Linux进程管理(ps、pstree、top、pidof、kill、nice、free)

    进程号(Process ID,PID) 1.ps命令(process status) 无选项时只显示从当前终端当前用户的进程 ps aux 是用BSD的格式来显示 java这个进程显示的项目有:USE ...

  10. 排错:golang运行http服务器直接挂掉无错误提示

    一运行就退出一运行就退出,没有报错提示检查代码也没有问题. 代码也没问题,原来是端口被占用了,改成8888就正常了