Codeforces 278B Books】的更多相关文章

好久没有写二分了 题意:有n本书 每本书有一个阅读时间ai 要在t时间内读最多的书 读书的顺序是连续的,如果无法读完一本书就不能开始 最开始觉得会是个dp,但是动规方程写不出来.想想会不会是二分呢,也写不出来 看了题解发现,输入的时候要做一个巧妙的处理 因为书是连续读的,如果ai存的是第1 到第i本书所用的时间总和的话, 那读[i,j]本书的时间就是ai-aj,这样就不需要循环算了啊! 于是固定一个起点 二分找终点 太久没写二分的结果就是 居然连二分的条件都不会了. #include<stdio…
http://codeforces.com/problemset/problem/279/B 题意 :Valera 有很多的空闲时间,所以他决定看书,给出n本书,编号1到n,和看每本书需要的时间,他看书是随机的,然后是连续的,从第 i 本开始看,看完了会看第i+1本,然后是第i+2本,问他在时间 t 内最多能看多少本书. 思路 :一开始没看明白题意,以为把时间排序,从小开始往里加,后来才发现人家要求的是连续的.这个就是循环从头开始加,如果时间超了,就从第一本开始往外删. #include <io…
题意:给定n本书的阅读时间,然后你从第 i 本开始阅读,问你最多能看多少本书在给定时间内. 析:就是一个滑动窗口的水题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream>…
B. Vanya and Books Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/problem/B Description Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the n books sh…
http://codeforces.com/contest/1066/problem/C You have got a shelf and want to put some books on it. You are given qq queries of three types: L idid — put a book having index idid on the shelf to the left from the leftmost existing book; R idid — put…
题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <vector> #include <string> #include <queue> #incl…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vanya got an important task - he should enumerate books in the library and label each book with its number. Each of the n books should be assigne…
B. Vanya and Books time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya got an important task - he should enumerate books in the library and label each book with its number. Each of the n …
题目链接:http://codeforces.com/problemset/problem/1249/B2 思路:用并查集模拟链表,把关系串联起来,如果成环,则满足题意.之后再用并查集合并一个链,一个链代表 一个集合,一个集合有共同的祖先,一个集合答案相同,则输出答案时候只需要输出该元素属于哪一个集合,那个集合有几个元素 就可以了. #include <stdio.h> #include <iostream> using namespace std; ; int fa[N]; in…
题意:给出n本书,总的时间t,每本书的阅读时间a[i],必须按照顺序来阅读,问最多能够阅读多少本书 有点像紫书的第七章讲的那个滑动区间貌似 维护一个区间的消耗的时间小于等于t,然后维护一个区间的最大值 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<ma…