题目链接: http://codeforces.com/problemset/problem/699/A 题目大意: 给N个点,向左或向右运动,速度均为1,问最早什么时候有两个点相撞.无解输出-1 题目思路: [模拟] 模拟一下,记录往左往右的位置即可. // //by coolxxx ////<bits/stdc++.h> #include<iostream> #include<algorithm> #include<string> #include<…
枚举相邻两个$a[i]$与$a[i+1]$,如果$s[i]=R$并且$s[i+1]=L$,那么$i$和$i+1$会碰撞,更新答案. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #incl…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n parti…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n parti…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n parti…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output   There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n par…
维护最新的R,遇到L时如果R出现过就更新答案. #include <cstdio> #include <algorithm> using namespace std; int n,x,r=-1,ans=-1; char a[200005]; int main(){ scanf("%d%s",&n,a); for(int i=0;i<n;i++){ scanf("%d",&x); if(a[i]=='R') r=x; el…
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, 然后接下来的t秒需要的蜡烛都燃烧着,超过t秒,每减少一秒灭一支蜡烛,好!!! 详细解释:http://blog.csdn.net/kalilili/article/details/43412385 */ #include <cstdio> #include <algorithm> #i…
题目地址:http://codeforces.com/problemset/problem/350/C /* 题意:机器人上下左右走路,把其他的机器人都干掉要几步,好吧我其实没读懂题目, 看着样例猜出来的,这题也蛮水的 模拟+贪心:sort一下,从最近的开始走 注意:坐标有一个为0的比普通的少一半的步骤,每次干掉一个要返回原来的位置 */ #include <cstdio> #include <iostream> #include <algorithm> #includ…
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单,依据公式得知折线一定是一上一下的,只要把两个相邻的坐标之间的折线填充就好 注意:坐标有可能为负数,所以移动值y初始化为1000,最后要倒过来输出 详细解释:http://blog.csdn.net/zhb1997/article/details/27877783 */ #include <cstd…