题目链接

http://codeforces.com/contest/1009

A. Game Shopping

直接模拟即可,用了一个队列来存储账单

#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#define ll long long
using namespace std; const int MAX = ; queue<int> bill;
int c[MAX];
int main(){
int gameNum, billNum;
cin >> gameNum >> billNum;
int t;
for(int i = ; i < gameNum; i++) cin >> c[i];
for(int i = ; i < billNum; i++){
cin >> t;
bill.push(t);
}
int ans = ;
int x = bill.front();
for(int i = ; i < gameNum; i++){
if(x >= c[i]){
ans++;
bill.pop();
if(bill.empty()) break;
x = bill.front();
}
}
cout << ans << endl;
}

B. Minimum Ternary String

思维题

题意是10可以互换位置,12可以互换位置,求将输入序列转为最小字典序

可以发现,1是可以处于序列中任何位置的,因此我们记录1的数量,构造这样一个序列

在第一个2前插入所有1,这样能使的2全部往后靠到最后

注意不要忽略没有2的序列情况

#include <iostream>
#include <cstdio>
#include <algorithm>
#define ll long long using namespace std; int const MAX = ; int main(){
int a[MAX];
char c;
int len = ;
while((c = getchar()) != '\n'){
a[len++] = c - '';
}
int oneNum = ;
for(int i = ; i < len; i++){
if(a[i] == ){
oneNum++;
}//1可以放置于任意位置,先全部取出
}
for(int i = ; i < len; i++){
if(a[i] == ){
cout << ;
}
else if(a[i] == ){
while(oneNum){
cout << ;
oneNum--;
}
cout << ;
}
}
while(oneNum){
cout << ;
oneNum--;
}
cout << endl;
}

C. Annoying Present

通过特定变换使得数列平均值达到最大

只要稍微分类一下就可以计算出各种情况

应该考虑精度问题,使用cout应该设置精度

#include <iostream>
#include <algorithm>
#include <iomanip>
#define ll long long
using namespace std; const int MAX = ; ll sum(int n){
ll ans = ;
for(int i = ; i <= n; i++){
ans+=i;
}
return ans;
} int main(){
ll x, d;
ll ans = , n, m;
cin >> n >> m;
ll t1 = sum(n-);
if(n% == ){
ll t2 = sum((n-)/);
for(int i = ; i < m; i++){
cin >> x >> d;
ans+=x*n;
if(d >= ){
ans+=d*t1;
}
else{
ans += *d*t2;
}
}
}
else{
ll t2 = sum(n/-);
for(int i = ; i < m; i++){
cin >> x >> d;
ans+=x*n;
if(d >= ){
ans+=d*t1;
}
else{
ans += *d*t2+n*d/;
}
}
}
cout.precision();
cout << ans*1.0/n << endl;
}

cordforce Educational Codeforces Round 47 补题笔记 <未完>的更多相关文章

  1. Educational Codeforces Round 27 补题

    题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...

  2. Educational Codeforces Round 23 补题小结

    昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> ...

  3. Educational Codeforces Round 12补题 经典题 再次爆零

    发生了好多事情 再加上昨晚教育场的爆零 ..真的烦 题目链接 A题经典题 这个题我一开始推公式wa 其实一看到数据范围 就算遍历也OK 存在的问题进制错误 .. 思路不清晰 两个线段有交叉 并不是端点 ...

  4. Educational Codeforces Round 22 补题 CF 813 A-F

    A The Contest 直接粗暴贪心 略过 #include<bits/stdc++.h> using namespace std; int main() {//freopen(&qu ...

  5. Educational Codeforces Round 47 (Rated for Div. 2) 题解

    题目链接:http://codeforces.com/contest/1009 A. Game Shopping 题目: 题意:有n件物品,你又m个钱包,每件物品的价格为ai,每个钱包里的前为bi.你 ...

  6. Educational Codeforces Round 47 (Div 2) (A~G)

    目录 Codeforces 1009 A.Game Shopping B.Minimum Ternary String C.Annoying Present D.Relatively Prime Gr ...

  7. Educational Codeforces Round 47 (Rated for Div. 2) :E. Intercity Travelling

    题目链接:http://codeforces.com/contest/1009/problem/E 解题心得: 一个比较简单的组合数学,还需要找一些规律,自己把方向想得差不多了但是硬是找不到规律,还是 ...

  8. Educational Codeforces Round 47 (Rated for Div. 2) :B. Minimum Ternary String

    题目链接:http://codeforces.com/contest/1009/problem/B 解题心得: 题意就是给你一个只包含012三个字符的字符串,位置并且逻辑相邻的字符可以相互交换位置,就 ...

  9. Educational Codeforces Round 15 套题

    这套题最后一题不会,然后先放一下,最后一题应该是大数据结构题 A:求连续最长严格递增的的串,O(n)简单dp #include <cstdio> #include <cstdlib& ...

随机推荐

  1. 数据结构之C语言模拟整数数组实现

    #include <stdio.h> #include <malloc.h> #include <stdlib.h> typedef struct Arr { in ...

  2. js的事件冒泡

    先来段代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

  3. macOS 从睡眠中恢复出来之后没有声音的解决方案

    打开Active Monitor, 找到coreaudiod进程, 将其quit掉即可

  4. HDU 5592——ZYB's Premutation——————【线段树单点更新、单点查询】

    ZYB's Premutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  5. ubuntu 下安装配置LAMP

    详情见: http://www.linuxeden.com/html/softuse/20130731/141934.html

  6. C#获取文件格式图标关联应用程序图标

    class SystemIcon { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct SHFIL ...

  7. c#ArrayList 对象集合 按某字段(属性)排序

    主程序代码 newsCompare newsCompare = new ItemManage.newsCompare(); newsList.Sort(newsCompare); 自定义类代码(按照C ...

  8. [原创] Debian9上配置软件阵列

    序言 软阵列是用软件实现的磁盘阵列. 准备工作 1. 更新系统 没啥,就他喵想用个最新的. apt update && apt upgrade 2. 安装mdadm 如果系统没有自带m ...

  9. [javascript]什么是闭包?

    http://www.zcfy.cc/article/master-the-javascript-interview-what-is-a-closure-2127.html

  10. selenium profile remotedriver

    使用 FirefoxProfile FirefoxProfilefp = new FirefoxProfile(); // set something on the profile... Desire ...