HDU多校Round 1
Solved:5
rank:172
A.Maximum Multiple
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll; int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int n;
scanf("%d", &n);
ll ans = -;
if(n % == )
{
ll x = n / ;
ans = max(ans, x * x * x);
}
if(n % == )
{
ll x = n / ;
ans = max(ans, x * x * x * );
}
printf("%lld\n", ans);
}
return ;
}
B.Balanced Sequence
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
using namespace std; char s[];
struct node
{
int l, r;
}E[]; bool cmp(node A, node B)
{
int tmp1 = min(A.l, B.r);
int tmp2 = min(A.r, B.l);
if(tmp1 == tmp2) return A.r < B.r;
else return tmp1 > tmp2;
} int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int ans = ; int cnt = ;
int suml = , sumr = ;
int n;
scanf("%d", &n);
for(int i = ; i <= n; i++)
{
scanf("%s", s);
int len = strlen(s); int cnl = , cnr = ;
for(int j = ; j < len; j++)
{
if(s[j] == '(') cnl++;
else
{
if(cnl)
{
cnl--;
ans += ;
}
else cnr++;
}
}
if(cnl == ) sumr += cnr;
else if(cnr == ) suml += cnl;
else
{
cnt++;
E[cnt].l = cnl;
E[cnt].r = cnr;
}
}
sort(E + , E + + cnt, cmp); for(int i = ; i <= cnt; i++)
{
if(suml >= E[i].r)
{
ans += E[i].r * ;
suml -= E[i].r;
suml += E[i].l;
}
else
{
ans += suml * ;
suml = E[i].l;
}
}
ans += min(suml, sumr) * ;
printf("%d\n", ans);
}
return ;
}
HDU多校Round 1的更多相关文章
- HDU多校Round 8
Solved:2 rank:141 D. Parentheses Matrix n,m有一个小于6的时候是一种构造方法 答案是n + (m - 2) / 2 (n > m) 都大于6的时候 可以 ...
- HDU多校Round 7
Solved:2 rank:293 J. Sequense 不知道自己写的什么东西 以后整数分块直接用 n / (n / i)表示一个块内相同n / i的最大i #include <bits/s ...
- HDU多校Round 6
Solved:2 rank:452 I. Werewolf 没有铁人 找铁狼 如果一个环中只有一条狼人边那个人就是铁狼 说铁狼是好人的人也是铁狼 #include <bits/stdc++.h& ...
- HDU多校Round 5
Solved:3 rank:71 E. Everything Has Changed #include <bits/stdc++.h> using namespace std; const ...
- HDU多校Round 4
Solved:3 rank:405................................. B. Harvest of Apples 知道了S(n,m) 可以o(1)的求S(n - 1, m ...
- HDU多校Round 3
Solved:4 rank:268 C. Dynamic Graph Matching 状压DP一下 #include <stdio.h> #include <algorithm& ...
- hdu 5667 BestCoder Round #80 矩阵快速幂
Sequence Accepts: 59 Submissions: 650 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- hdu 5643 BestCoder Round #75
King's Game Accepts: 249 Submissions: 671 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6 ...
- hdu 5641 BestCoder Round #75
King's Phone Accepts: 310 Submissions: 2980 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
随机推荐
- spring 的核心接口
spring有两个核心接口,BeanFactory 和ApplicationContext ,其中ApplicationContext 是BeanFactory的子接口.他们代表了Spring容器. ...
- 记录一下收集到的clojure相关的东东
https://github.com/plexus/chestnut 一个用来调试clojurescript的工具,解决 Clojure, ClojureScript, and CSS的reload问 ...
- 服务器可用的Socket
"; IPAddress ServerIp = IPAddress.Parse("112.124.46.251"); IPEndPoint iep = new IPEnd ...
- shell脚本自动更新git
gitpull.sh #!/bin/bash cd /home/wwwroot/default/mouse && git pull cd /home/wwwroot/default/s ...
- E2017614-hm
pluck n. 勇气,精神; 内脏; 快而猛的拉; 〈俚〉不及格; vt. 拔掉; 采,摘; 鼓起(勇气等); 弹(乐器); scope n. (处理.研究事务的) 范围; 眼界,见识 ...
- bzoj 1633: [Usaco2007 Feb]The Cow Lexicon 牛的词典【dp】
预处理出g[i][j]表示原串第i个匹配第j个单词需要去掉几个字母(匹配不上为-1) 设f[i]为i及之后满足条件要去掉的最少字母 倒着dp! f[i]初始为f[i+1]+1,转移方程为f[i]=mi ...
- 商品期货高频交易策略Tick框架
原帖地址:https://www.fmz.com/bbs-topic/1184在商品期货高频交易策略中, Tick行情的接收速度对策略的盈利结果有着决定性的影响,但市面上大多数交易框架,都是采用回调模 ...
- Java实现短信中提取号码
Description 提取一条短信里所有的电话号码,电话号码之间换行打印,短信的内容由用户输入. Input 第一行有个整数n(1≤n≤1000)表示测试用例的个数.其后的每一行中有一条短信,每一条 ...
- 【计蒜客习题】 取石子游戏(gcd)
问题描述 蒜头君和花椰妹在玩一个游戏,他们在地上将 n 颗石子排成一排,编号为 1 到 n.开始时,蒜头君随机取出了 2 颗石子扔掉,假设蒜头君取出的 2 颗石子的编号为 a, b.游戏规则如下,蒜头 ...
- 贪心+优先队列 HDOJ 5360 Hiking
题目传送门 /* 题意:求邀请顺序使得去爬山的人最多,每个人有去的条件 贪心+优先队列:首先按照l和r从小到大排序,每一次将当前人数相同的被邀请者入队,那么只要能当前人数比最多人数条件小,该人能 被邀 ...