水 A - Vasya the Hipster

/************************************************
* Author :Running_Time
* Created Time :2015/9/28 星期一 16:58:13
* File Name :A.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-8; int main(void) {
int a, b; scanf ("%d%d", &a, &b);
int ans = min (a, b);
printf ("%d ", ans);
a -= ans, b -= ans;
ans = a / 2 + b / 2;
printf ("%d\n", ans); return 0;
}

水 B - Luxurious Houses

从后往前,维护一个后缀最大值

/************************************************
* Author :Running_Time
* Created Time :2015/9/28 星期一 16:58:21
* File Name :B.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
int a[N], mx[N], ans[N]; int main(void) {
int n; scanf ("%d", &n);
for (int i=1; i<=n; ++i) {
scanf ("%d", &a[i]);
}
mx[n] = a[n]; ans[n] = 0;
for (int i=n-1; i>=1; --i) {
if (a[i] <= mx[i+1]) {
ans[i] = mx[i+1] + 1 - a[i];
}
mx[i] = max (mx[i+1], a[i]);
} for (int i=1; i<=n; ++i) {
printf ("%d%c", ans[i], i == n ? '\n' : ' ');
} return 0;
}

  

贪心 C - Developing Skills

题意:给n个数,最多可以增加k,每个数上限为100,问max sum (a[i] / 10)

分析:若k很小时,优先加给需要最小数字能到下一个十整数的,按照这个规则排序。若还有多余则继续,此时每个数字加10,直到100或者k<=0,及时break。

/************************************************
* Author :Running_Time
* Created Time :2015/9/28 星期一 16:58:28
* File Name :C.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
int a[N]; int cal(int x) {
if (x == 100) return 0;
int a = x / 10;
return (a + 1) * 10 - x;
} bool cmp(int x, int y) {
return cal (x) < cal (y);
} int main(void) {
int n, k; scanf ("%d%d", &n, &k);
for (int i=1; i<=n; ++i) {
scanf ("%d", &a[i]);
}
sort (a+1, a+1+n, cmp);
while (k > 0) {
bool up = false;
for (int i=1; i<=n; ++i) {
if (a[i] == 100) continue;
int dt = cal (a[i]);
if (dt > k || k <= 0) break;
if (dt <= k) {
k -= dt; a[i] += dt;
up = true;
}
}
if (!up) break;
} int ans = 0;
for (int i=1; i<=n; ++i) {
ans += a[i] / 10;
}
printf ("%d\n", ans); return 0;
}

  

模拟 D - Three Logos

题意:很好理解,就是三个矩形组合成一个正方形

分析:想到了很简单,无非就是两种情况,比赛时没想那么多,代码很挫,建议看图片就行了。。。

/************************************************
* Author :Running_Time
* Created Time :2015/9/28 星期一 17:39:02
* File Name :D.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-8; int main(void) {
int x[3], y[3];
for (int i=0; i<3; ++i) {
scanf ("%d%d", &x[i], &y[i]);
if (x[i] > y[i]) swap (x[i], y[i]);
}
int sx = x[0] + x[1] + x[2];
if (sx == y[0] && sx == y[1] && sx == y[2]) { //第一种情况
printf ("%d\n", sx);
for (int i=0; i<3; ++i) {
for (int j=1; j<=x[i]; ++j) {
for (int k=1; k<=y[i]; ++k) {
printf ("%c", i == 0 ? 'A' : (i == 1) ? 'B' : 'C');
}
puts ("");
}
}
}
else { //第二种情况
bool flag = false;
int n = 0, id = 0;
for (int i=0; i<3; ++i) {
if (n < y[i]) {
n = y[i]; id = i;
}
}
int tx = n - x[id];
for (int i=0; i<3; ++i) {
for (int j=0; j<3; ++j) {
if (i == id || j == id) continue;
if (x[i] == x[j] && x[i] == tx) {
if (y[i] + y[j] == n) {
flag = true; break;
}
}
else if (x[i] == y[j] && x[i] == tx) {
if (y[i] + x[j] == n) {
flag = true; break;
}
}
else if (y[i] == x[j] && y[i] == tx) {
if (x[i] + y[j] == n) {
flag = true; break;
}
}
else if (y[i] == y[j] && y[i] == tx) {
if (x[i] + x[j] == n) {
flag = true; break;
}
}
}
} if (flag) { //输出答案
printf ("%d\n", n);
for (int i=1; i<=x[id]; ++i) {
for (int j=1; j<=y[id]; ++j) {
printf ("%c", id == 0 ? 'A' : (id == 1) ? 'B' : 'C');
}
puts ("");
}
char p, q;
if (id == 0) p = 'B', q = 'C';
else if (id == 1) p = 'A', q = 'C';
else p = 'A', q = 'B';
for (int i=0; i<3; ++i) {
for (int j=0; j<3; ++j) {
if (i == id || j == id) continue;
if (x[i] == x[j] && x[i] == tx) {
if (y[i] + y[j] == n) {
for (int k=1; k<=tx; ++k) {
for (int l=1; l<=n; ++l) {
printf ("%c", l <= y[i] ? p : q);
}
puts ("");
}
return 0;
}
}
else if (x[i] == y[j] && x[i] == tx) {
if (y[i] + x[j] == n) {
for (int k=1; k<=tx; ++k) {
for (int l=1; l<=n; ++l) {
printf ("%c", l <= y[i] ? p : q);
}
puts ("");
}
return 0;
}
}
else if (y[i] == x[j] && y[i] == tx) {
if (x[i] + y[j] == n) {
for (int k=1; k<=tx; ++k) {
for (int l=1; l<=n; ++l) {
printf ("%c", l <= x[i] ? p : q);
}
puts ("");
}
return 0;
}
}
else if (y[i] == y[j] && y[i] == tx) {
if (x[i] + x[j] == n) {
for (int k=1; k<=tx; ++k) {
for (int l=1; l<=n; ++l) {
printf ("%c", l <= x[i] ? p : q);
}
puts ("");
}
return 0;
}
}
}
}
}
else puts ("-1");
} return 0;
}

 

最后老夫夜观星相,预测此次rating会超1700,为了能够在div2继续虐菜,“故意”hack失败。。

Codeforces Round #322 (Div. 2)的更多相关文章

  1. Codeforces Round #322 (Div. 2) D. Three Logos 暴力

    D. Three Logos Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/problem ...

  2. Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列

    C. Developing Skills Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  3. Codeforces Round #322 (Div. 2) B. Luxurious Houses 水题

    B. Luxurious Houses Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/pr ...

  4. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  5. Codeforces Round #322 (Div. 2) —— F. Zublicanes and Mumocrates

    It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The ...

  6. Codeforces Round #322 (Div. 2) E F

    E. Kojiro and Furrari 题意说的是 在一条直线上 有n个加油站, 每加一单位体积的汽油 可以走1km 然后每个加油站只有一种类型的汽油,汽油的种类有3种 求从起点出发到达终点要求使 ...

  7. 树形dp - Codeforces Round #322 (Div. 2) F Zublicanes and Mumocrates

    Zublicanes and Mumocrates Problem's Link Mean: 给定一个无向图,需要把这个图分成两部分,使得两部分中边数为1的结点数量相等,最少需要去掉多少条边. ana ...

  8. Codeforces Round #322 (Div. 2) D. Three Logos 模拟

                                                      D. Three Logos Three companies decided to order a ...

  9. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

随机推荐

  1. HDOJ_ How can I read input data until the end of file ?

    Language C C++ Pascal To read numbers int n;while(scanf("%d", &n) != EOF){ ...} int n; ...

  2. dubbo配置指南

    dubbo配置指南 SLA配置在此完成!Service Layer Agreement ApplicationConfig 应用配置,用于配置当前应用信息,不管该应用是提供者还是消费者. Regist ...

  3. zTree async 动态参数处理

    async:{ enable: true,//开启异步机制 url: opts.url,//异步地址 otherParam: {  'plateNo': function(){ return $('# ...

  4. LOJ#139. 树链剖分

    LOJ#139. 树链剖分 题目描述 这是一道模板题. 给定一棵$n$个节点的树,初始时该树的根为 1 号节点,每个节点有一个给定的权值.下面依次进行 m 个操作,操作分为如下五种类型: 换根:将一个 ...

  5. Springboot读取自定义的yml文件中的List对象

    Yml文件(novellist.xml)如下: novellist:   list:     - name: 笑傲江湖       type: 武侠       master: 令狐冲       a ...

  6. mysql_proxy

    mysql_proxy中间件实现:读写分离.负载均衡. mysql_proxy中间件实现:读写分离.负载均衡. 负载均衡:给多台数据库,看能不能均匀的分给不同的数据库. 客户端连的是proxy,此时的 ...

  7. aop+自定义注解

    自定义注解,并且实现,需要两个文件: 自定义注解类: package com.clc.server.annotation; import java.lang.annotation.ElementTyp ...

  8. bootstrap学习心得

    一.html的编写规范 <!DOCTYPE html> <html lang="zh-CN"> <head> <title>Page ...

  9. [RK3288][Android6.0] 调试笔记 --- 测试I2C设备正常传输方法【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/71515020 Platform: RockchipOS: Android 6.0Kernel ...

  10. 请问snmp到底是干啥的。

    这个事情分两方面来说:首先是路由器这部分.路由器开启SNMP功能之后,它能够对自己的每个接口上的流量有一个统计,当然统计的不单单只有流量.然后路由器把统计到的内容按一定的格式保存起来.这个格式是大家都 ...