cordforce Educational Codeforces Round 47 补题笔记 <未完>
题目链接
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 补题笔记 <未完>的更多相关文章
- Educational Codeforces Round 27 补题
题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...
- Educational Codeforces Round 23 补题小结
昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> ...
- Educational Codeforces Round 12补题 经典题 再次爆零
发生了好多事情 再加上昨晚教育场的爆零 ..真的烦 题目链接 A题经典题 这个题我一开始推公式wa 其实一看到数据范围 就算遍历也OK 存在的问题进制错误 .. 思路不清晰 两个线段有交叉 并不是端点 ...
- Educational Codeforces Round 22 补题 CF 813 A-F
A The Contest 直接粗暴贪心 略过 #include<bits/stdc++.h> using namespace std; int main() {//freopen(&qu ...
- Educational Codeforces Round 47 (Rated for Div. 2) 题解
题目链接:http://codeforces.com/contest/1009 A. Game Shopping 题目: 题意:有n件物品,你又m个钱包,每件物品的价格为ai,每个钱包里的前为bi.你 ...
- Educational Codeforces Round 47 (Div 2) (A~G)
目录 Codeforces 1009 A.Game Shopping B.Minimum Ternary String C.Annoying Present D.Relatively Prime Gr ...
- Educational Codeforces Round 47 (Rated for Div. 2) :E. Intercity Travelling
题目链接:http://codeforces.com/contest/1009/problem/E 解题心得: 一个比较简单的组合数学,还需要找一些规律,自己把方向想得差不多了但是硬是找不到规律,还是 ...
- Educational Codeforces Round 47 (Rated for Div. 2) :B. Minimum Ternary String
题目链接:http://codeforces.com/contest/1009/problem/B 解题心得: 题意就是给你一个只包含012三个字符的字符串,位置并且逻辑相邻的字符可以相互交换位置,就 ...
- Educational Codeforces Round 15 套题
这套题最后一题不会,然后先放一下,最后一题应该是大数据结构题 A:求连续最长严格递增的的串,O(n)简单dp #include <cstdio> #include <cstdlib& ...
随机推荐
- nginx+keepalived主辅切换(监控脚本在keepalived.conf中执行)
以前写过一篇,nginx+keepalived 双机互备的文章,写那篇文章的时候没有想过如果apache或者nginx 挂了,而 keepalived 或者 机器没有死,那么主辅是不会切换的,今天就研 ...
- pat06-图4. Saving James Bond - Hard Version (30)
06-图4. Saving James Bond - Hard Version (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作 ...
- SQL命令行操作
命令行操作(mysql.exe) 0.登录 : mysql -u root -p 1.显示数据库列表: show databases; 2.选择数据库: ...
- http request 字段
Accept: 客户端支持的文件类型, 如果为/表示任何类型 Accept-Encoding: 客户端浏览器支持的文件压缩格式 Accept-Language: 客户端支持的语言 User-Agent ...
- mongodb 用户权限控制
MongoDB已经使用很长一段时间了,基于MongoDB的数据存储也一直没有使用到权限访问(MongoDB默认设置为无权限访问限制),今天特地花了一点时间研究了一下,研究成果如下: 注:研究成果基于W ...
- C#设计模式——单例
单例模式是设计模式中最简单的形式之一.这一模式的目的是使得类的一个对象成为系统中的唯一实例.对于系统中的某些类来说,只有一个实例很重要,例如,一个系统中可以存在多个打印任务,但是只能有一个正在工作的任 ...
- 获取iframe子页面节点,响应浏览器宽高
获取iframe子页面节点,响应浏览器宽高 html部分代码 <div> <iframe width="100%" height="100%" ...
- Dictionary and KeyValuePair.
简单一句话: Dictionary 是 由 KeyValuePair结构 组成的集合 The Dictionary<TKey, TValue>.Enumerator.Current pro ...
- 【Android 界面效果49】RecyclerView高度随Item自适应
编写RecyclerView.ItemDecoration时,在onDraw方法中,Drawable的高度等于RecyclerView的高度减去RecyclerView的上下padding. @Ove ...
- 《ArcGIS Runtime SDK for Android开发笔记》——(6)、基于Android Studio的ArcGIS Android工程结构解析
1.前言 Android Studio 是第一个Google官方的 Android 开发环境.其他工具,例如 Eclipse,在 Android Studio 发布之前已经有了大规模的使用.为了帮助开 ...