【Codeforces】Round #376 (Div. 2)
http://codeforces.com/contest/731
不发题面了,自己点链接
总结一下
考场上
原以为这次要加很多raiting。。。
但FST狗记邓,只加了58rating
总结一下
- ABC切得很快(保持)
- B题WA了2发不应该,没有想清楚
- F题写了大暴力,但不优美,虽然过了P,但就没有想了,很严重问题,得意忘形,虽然知道FST,但有侥幸心里,真正考试就完了
- 以为拿到了分就不干事了,严重问题,真正考试一定要写暴力拍
- 后来没有干事,既没有hack又没有去写DE不应该
A Night at the Museum
Solution:Implementation,String
// <A.cpp> - Sun Oct 16 17:45:40 2016
// This file is made by YJinpeng,created by XuYike's black technology automatically.
// Copyright (C) 2016 ChangJun High School, Inc.
// I don't know what this program is. #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define MOD 1000000007
#define INF 1e9
using namespace std;
typedef long long LL;
const int MAXN=110;
inline int gi() {
register int w=0,q=0;register char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')q=1,ch=getchar();
while(ch>='0'&&ch<='9')w=w*10+ch-'0',ch=getchar();
return q?-w:w;
}
char s[MAXN];
int main()
{
freopen("A.in","r",stdin);
freopen("A.out","w",stdout);
scanf("%s",s);int l=strlen(s);
char ch='a';int ans=0;
for(int i=0;i<l;i++)
ans+=min((s[i]-ch+26)%26,(ch-s[i]+26)%26),ch=s[i];
printf("%d",ans);
return 0;
}
B Coupons and Discounts
题目大意:每天要买a[i]个东西,买的方式有两种:两天一天买一个 or 一天买两个,问是否有合法方案
Solution:Greedy+递推,考虑一天,奇数的话必须要用第一种方式,那就之后那天要买一个,几个flag即可,一路推过去,<0不合法,偶数的话直接用第二种→ 贪心,不用麻烦后面那天。
反思:居然wa了两发,7~80分啊。。(notice 最后一次是否要之后填充,flag清空)
// <B.cpp> - Sun Oct 16 17:45:40 2016
// This file is made by YJinpeng,created by XuYike's black technology automatically.
// Copyright (C) 2016 ChangJun High School, Inc.
// I don't know what this program is. #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define MOD 1000000007
#define INF 1e9
using namespace std;
typedef long long LL;
const int MAXN=100010;
const int MAXM=100010;
inline int gi() {
register int w=0,q=0;register char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')q=1,ch=getchar();
while(ch>='0'&&ch<='9')w=w*10+ch-'0',ch=getchar();
return q?-w:w;
}
void pri(){printf("NO");exit(0);}
int main()
{
freopen("B.in","r",stdin);
freopen("B.out","w",stdout);
int n=gi(),last=0;
for(int i=1;i<=n;i++){
int x=gi()-last;
if(x<0)pri();
if(x&1)last=1;else last=0;
}if(last)pri();else printf("YES");
return 0;
}
C Socks
有n只袜子,每只袜子有一个颜色,有一些约束(即某天的左右两边袜子颜色要相同),然后问你最少要改多少只?
显然并查集,然后贪心,一个联通块内的颜色要全相同,Greedy-找出颜色已经相同的最多数目,答案加上其他要改的即可
// <C.cpp> - Sun Oct 16 17:45:40 2016
// This file is made by YJinpeng,created by XuYike's black technology automatically.
// Copyright (C) 2016 ChangJun High School, Inc.
// I don't know what this program is. #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define MOD 1000000007
#define INF 1e9
using namespace std;
typedef long long LL;
const int MAXN=200010;
inline int gi() {
register int w=0,q=0;register char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')q=1,ch=getchar();
while(ch>='0'&&ch<='9')w=w*10+ch-'0',ch=getchar();
return q?-w:w;
}
int f[MAXN],a[MAXN],c[MAXN];vector<int>b[MAXN];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
int main()
{
freopen("C.in","r",stdin);
freopen("C.out","w",stdout);
int n=gi(),m=gi(),k=gi(),ans=0;k++;
for(int i=1;i<=n;i++)a[i]=gi(),f[i]=i;
while(m--){
int l=gi(),r=gi();
if(find(l)!=find(r))f[f[l]]=f[r];
}
for(int i=1;i<=n;i++)
b[find(i)].push_back(i);
for(int i=1;i<=n;i++){
if(f[i]!=i)continue;int now=0;
for(int j=0,to=b[i].size();j<to;j++){
c[a[b[i][j]]]++;
if(c[a[b[i][j]]]>now)now=c[a[b[i][j]]];
}
ans+=b[i].size()-now;
for(int j=0,to=b[i].size();j<to;j++)c[a[b[i][j]]]--;
}printf("%d",ans);
return 0;
}
D
挖坑~
E
挖坑~
F Video Cards
给你一列数a[],选择一个标准,使得其他的数减小至他的倍数,使得和最大?
// <F.cpp> - Sun Oct 16 17:45:40 2016
// This file is made by YJinpeng,created by XuYike's black technology automatically.
// Copyright (C) 2016 ChangJun High School, Inc.
// I don't know what this program is. #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long LL;
const int MAXN=200010;
inline int gi() {
register int w=0,q=0;register char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')q=1,ch=getchar();
while(ch>='0'&&ch<='9')w=w*10+ch-'0',ch=getchar();
return q?-w:w;
}
int a[MAXN];LL f[MAXN];
int main()
{
int n=gi();LL ans=0;
for(int i=1;i<=n;i++)a[i]=gi();
sort(a+1,a+1+n);
for(int i=1;i<=n;i++)f[i]=f[i-1]+a[i];
for(int i=1;i<=n;i++){
LL now=a[i];
for(int j=n;j>i;j--){
if(now+f[j]-f[i]<=ans)break;
now+=a[j]/a[i]*a[i];
}
if(now>ans)ans=now;
}printf("%I64d",ans);
return 0;
}
AC-暴力+统计
// <F.cpp> - Sun Oct 16 17:45:40 2016
// This file is made by YJinpeng,created by XuYike's black technology automatically.
// Copyright (C) 2016 ChangJun High School, Inc.
// I don't know what this program is. #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long LL;
const int MAXN=200001;
inline int gi() {
register int w=0,q=0;register char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')q=1,ch=getchar();
while(ch>='0'&&ch<='9')w=w*10+ch-'0',ch=getchar();
return q?-w:w;
}
LL s[MAXN];int a[MAXN];
int main()
{
freopen("F.in","r",stdin);
freopen("F.out","w",stdout);
int n=gi();LL ans=0;
for(int i=1;i<=n;i++)a[gi()]++;
for(int i=1;i<MAXN;i++)s[i]=s[i-1]+a[i];
for(int i=1;i<MAXN;i++)
if(a[i]){
LL now=0;int t=MAXN/i;
for(int j=1;j<t;j++)
now+=1LL*(s[i*(j+1)-1]-s[i*j-1])*j*i;
now+=1LL*(s[MAXN-1]-s[i*t-1])*i*t;
if(now>ans)ans=now;
}
printf("%lld",ans);
return 0;
}
【Codeforces】Round #376 (Div. 2)的更多相关文章
- 【Codeforces】Round #491 (Div. 2) 总结
[Codeforces]Round #491 (Div. 2) 总结 这次尴尬了,D题fst,E没有做出来.... 不过还好,rating只掉了30,总体来说比较不稳,下次加油 A:If at fir ...
- 【Codeforces】Round #488 (Div. 2) 总结
[Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rat ...
- 【Codeforces】Round #375 (Div. 2)
Position:http://codeforces.com/contest/723 我的情况 啊哈哈,这次raiting肯定要涨,接受过上次的教训,先用小号送肉,大号都是一发切,重回蓝咯 结果... ...
- 【Codeforces】 Round #374 (Div. 2)
Position:http://codeforces.com/contest/721 我的情况 开始还是rank1,秒出C.(11:00机房都走光了,我ma到11:05才走,只打了一个小时) 结果.. ...
- 【Codeforces】Round #460 E - Congruence Equation 中国剩余定理+数论
题意 求满足$na^n\equiv b \pmod p$的$n$的个数 因为$n \mod p $循环节为$p$,$a^n\mod p$循环节为$p-1$,所以$na^n \mod p$循环 ...
- 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 ...
- 【CF981F】Round Marriage(二分答案,二分图匹配,Hall定理)
[CF981F]Round Marriage(二分答案,二分图匹配,Hall定理) 题面 CF 洛谷 题解 很明显需要二分. 二分之后考虑如果判定是否存在完备匹配,考虑\(Hall\)定理. 那么如果 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
随机推荐
- buf.entries()详解
buf.entries() 返回:{Iterator} 从当前 Buffer 的内容中,创建并返回一个 [index, byte] 形式的迭代器. const buf = Buffer.from('b ...
- 19Spring返回通知&异常通知&环绕通知
在前置通知和后置通知的基础上加上返回通知&异常通知&环绕通知 代码: package com.cn.spring.aop.impl; //加减乘除的接口类 public interfa ...
- 关于解决ssh的"Write failed: Broken pipe"问题
操作环境: 服务器:微软云 Linux CentOS 虚拟机 客户端:MAC OSX terminal 问题描述: 登录虚拟机短时间内不操作就会断开连接并报该“Write failed: Broken ...
- 易维信(EVTrust)支招五大技巧识别钓鱼网站
网上购物和网上银行凭借其便捷性和通达性,在互联网上日渐流行.在互联网上,你可以随时进行转账汇款或进行交易.据艾瑞咨询发布<2008-2009年中国网上支付行业发展报告>显示:中国互联网支付 ...
- CodeForces 221D Little Elephant and Array
Little Elephant and Array Time Limit: 4000ms Memory Limit: 262144KB This problem will be judged on C ...
- POJ3669 Meteor Shower
http://poj.org/problem?id=3669 类似于迷宫的一道题 但是并没有 给出迷宫具体什么样 但是题目已说在坐标轴的第一象限 然后障碍就是 流星雨所砸范围 安全位置:永远不会发生危 ...
- [USACO08NOV]时间管理Time Management
题目描述 Ever the maturing businessman, Farmer John realizes that he must manage his time effectively. H ...
- poj——3687 Labeling Balls
Labeling Balls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14835 Accepted: 4346 D ...
- Word Search(深度搜索DFS,参考)
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from l ...
- 权限框架之Shiro详解(非原创)
文章大纲 一.权限框架介绍二.Shiro基础介绍三.Spring Boot整合Shiro代码实战四.项目源码与资料下载五.参考文章 一.权限框架介绍 1. 什么是权限管理 权限管理属于系统安全 ...