It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students are angry. Let's describe a group of students by a str…
网址:http://codeforces.com/problemset/problem/1287/A It's a walking tour day in SIS.Winter, so tt groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students ar…
Circle of Students time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn students standing in a circle in some order. The index of the ii-th student is pipi. It is guaranteed that a…
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard input output: standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships…
A. Robot Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Calvin the robot lies in an infinite rectangular grid. Calvin's source code contains a list of n commands, each either 'U'…
题目链接:http://codeforces.com/problemset/problem/589/D 题目大意:给出n个人行走的开始时刻,开始时间和结束时间,求每个人分别能跟多少人相遇打招呼(每两人只能打招呼一次). 例: 输入:31 1 105 8 29 9 10 输出: 2 1 1 解题思路:先按行走的开始时刻排下序,然后直接模拟判断和比他后出现的人是否可以相遇. 第一步判断前面那个人在未走完前,下一人会出现,若不出现,直接break.然后就计算当下一个人出现的时刻,前一个人的位置,然后又…
B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Finally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, b…
题目大意:托尔有一部手机可执行三种操作 1.x APP产生一个新消息 2.读取x App已产生的所有消息 3.读取前t个产生的消息 问每次操作后未读取的消息的数量 题目思路: 队列模拟,坑点在于竟然卡内存--详细看代码. #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h> #include<stdlib.h&g…
Codeforces 332 C 我爱对拍,对拍使我快乐... 题意:有\(n\)个议题,学生们会让议会同意\(p\)个,其中主席会执行\(k\)个, 每一个议题执行后主席会掉\(a_i\)的头发,不执行后议会会增加\(b_i\)的不开心值, 然后主席想让议会的不开心值最小,如果有多重方案就选自己头发掉的最少的: 而学生们想让主席的头发掉的最多,如果有多种方案让议会的不开心值最大. 问让议会同意哪\(p\)个会达到最好的效果. 思路1: 这是我的不对的思路. (虽然没提交 我们首先将所有的数按照…
大意: 给定2*n的矩阵, 每个格子有权值, 走到一个格子的贡献为之前走的步数*权值, 每个格子只能走一次, 求走完所有格子最大贡献. 沙茶模拟打了一个小时总算打出来了 #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #inc…