Codeforces 67A【模拟】
保证每个人拿糖>=1,在分糖最少的情况下,输出每个学生所分得的糖。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
const double eps=1e-5;
const double pi=acos(-1.0);
const int INF=0x3f3f3f3f; /*
老师分糖,给成绩好的人糖多。
给一个字符串代表学生拿糖的规律,有三种符号,L代表左边的人比自己高,R表示右边的高,=表示左右相等。
在保证分糖最少的情况下,输出每个学生所分得的糖。
*/ char stu[1010];
int dp[1010]; int main()
{
int n,len;
scanf("%d",&n);
scanf("%s",stu+1);
len=n;
dp[0]=1;
for(int i=1;i<len;i++)
{
if(stu[i]=='=')
dp[i]=dp[i-1];
else if(stu[i]=='R')
dp[i]=dp[i-1]+1;
else
{
if(dp[i-1]>1)
dp[i]=1;
else
{
dp[i]=1;
dp[i-1]++;
for(int j=i-1;j>=1;j--)
{
if(stu[j]=='=')
dp[j-1]=dp[j];
else if(stu[j]=='L')
{
if(dp[j-1]==dp[j])
dp[j-1]++;
else
break;
}
else
break;
}
}
}
}
for(int i=0;i<n;i++)
{
printf("%d ",dp[i]);
}
return 0;
}
Codeforces 67A【模拟】的更多相关文章
- CodeForces - 427B (模拟题)
Prison Transfer Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Sub ...
- CodeForces - 404B(模拟题)
Marathon Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Sta ...
- Codeforces 709B 模拟
B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...
- CodeForces - 404A(模拟题)
Valera and X Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- Codeforces 390A( 模拟题)
Inna and Alarm Clock Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64 ...
- Codeforces 452D [模拟][贪心]
题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...
- CodeForces - 796B 模拟
思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include ...
- CodeForces - 864C-Bus-(模拟加油站问题)
https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...
- Codeforces 709C 模拟
C. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:stand ...
随机推荐
- appium(5)-Appium capabilities
Appium Capabilities Appium server capabilities Capability Description Values automationName Which au ...
- spring事件广播
可参考:http://www.cnblogs.com/atyou/archive/2013/01/07/2850106.html 其中的类图更是精彩,现截至如下:
- Python序列——列表
列表是什么 1 创建列表 2 访问列表和更新列表 列表相关操作 内建函数对列表的支持 1 cmp 2 序列类型函数 列表内建函数 列表应用 1 堆栈 2 队列 1. 列表是什么 列表也是序列的一种.列 ...
- Codeforces Round #394 (Div. 2) B. Dasha and friends —— 暴力 or 最小表示法
题目链接:http://codeforces.com/contest/761/problem/B B. Dasha and friends time limit per test 2 seconds ...
- 扩散(diffusion)和弥散(dispersion)有什么区别
作者:谢易正链接:https://www.zhihu.com/question/23914350/answer/177359196来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注 ...
- php-循环普通数组和关联数组
<?php //循环普通数组 $arr=array("杭州","成都","拉萨"); $arrlength=count($arr); ...
- 阻止Eclipse一直building workspace
Eclipse 一直不停 building workspace完美解决总结 一.产生这个问题的原因多种 1.自动升级 2.未正确关闭 3.maven下载lib挂起 等.. 二.解决总结 (1).解决方 ...
- SPOJ(后缀数组求不同子串个数)
DISUBSTR - Distinct Substrings Given a string, we need to find the total number of its distinct subs ...
- Ubuntu 安装Guake
一款代替终端的软件, 只需按F12就可以调出终端, 再按就消失, 附上Github链接. https://github.com/Guake/guake 一开始没安装上去, 后来成功, 现在用着还不错, ...
- 2.1-2.2 Hive 中数据库(Table、Database)基本操作
官网文档:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL 一.create table 1.官方字段 # # C ...