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 ...
随机推荐
- python发送post请求上传文件,无法解析上传的文件
前言 近日,在做接口测试时遇到一个奇葩的问题. 使用post请求直接通过接口上传文件,无法识别文件. 遇到的问题 以下是抓包得到的信息: 以上请求是通过Postman直接发送请求的. 在这里可以看到消 ...
- 九度OJ 1138:进制转换 (进制转换)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2388 解决:935 题目描述: 将一个长度最多为30位数字的十进制非负整数转换为二进制数输出. 输入: 多组数据,每行为一个长度不超过30 ...
- Adjusting Network Connection
Adjusting Network Connection The Selenium Mobile JSON Wire Protocol Specification supports an API fo ...
- Unity编译时找不到AndroidSDK的问题 | Unable to list target platforms
解决方式 1.从官网下载一个旧版本的 Android SDK tools 25.2.3.tools_r25.2.3-windows.zip. 2. 解压 3. 替换原来sdk目录下tools
- Unity导包配置详解
Player Settings is where you define various parameters (platform specific) for the final game that y ...
- Docker的远程访问
$docker : info (10.211.55是另一台服务器的地址) 频繁访问远程的docker服务器使用-H选项很麻烦,使用环境变量DOCKER_HOST, $export DOCKER_HOS ...
- 一看就会,科目三靠边停车30cm技巧!再也不怕不会停车了!
靠边停车是科目三考试的最后一关,如果在这一关失败,那之前所有的努力都功亏一篑了,你感觉吃不吃亏?就连我们自己平时开车,轮胎万一与路边石阶刮蹭,就会造成不小的伤害.那么靠边停车时有哪些注意要点呢?请和小 ...
- iap 应用内购买相关的解释
应用范围app Store Review Guidelines : https://developer.apple.com/app-store/review/guidelines/ 中 11.12 ...
- the art of seo(chapter four)
SEO Implementation:First Stages ***Development Platform and Information Architecture***1.Technology ...
- hdu 3932 Groundhog Build Home —— 模拟退火
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3932 找一个位置使距离最远的点的距离最小: 上模拟退火: 每次向距离最远的点移动,注意判断一下距离最远的点 ...