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 ...
随机推荐
- java基础知识查漏 二
一.java基本数据类型所占的内存大小 在Java中一共有8种基本数据类型,其中有4种整型,2种浮点类型,1种用于表示Unicode编码的字符 单元的字符类型和1种用于表示真值的boolean类型.( ...
- static 静态域 类域 静态方法 工厂方法 he use of the static keyword to create fields and methods that belong to the class, rather than to an instance of the class 非访问修饰符
总结: 1.无论一个类实例化多少对象,它的静态变量只有一份拷贝: 静态域属于类,而非由类构造的实例化的对象,所有类的实例对象共享静态域. class Employee { private static ...
- Use Apache HBase™ when you need random, realtime read/write access to your Big Data.
Apache HBase™ is the Hadoop database, a distributed, scalable, big data store. Use Apache HBase™ whe ...
- 虚拟化(五):vsphere高可用群集与容错(存储DRS是一种可用于将多个数据存储作为单个数据存储群集进行管理的功能)
vsphere高级功能需要vcenter server和共享存储的支持才能实现.vsphere的高级功能有 vmotion.storage vmotion.vsphere HA.vsphere DRS ...
- POJO对象建立规则
1.所有POJO类属性必须使用包装数据类型,RPC方法的返回值和参数必须使用包装数据类型. 说明:POJO类属性没有初值是提醒使用者在使用时,必须自己显示的进行赋值,任何NPE问题,或者入库检查,都由 ...
- 12.HTML DOM 允许 JavaScript 改变 HTML 元素的内容。
1,改变 HTML 输出流 <script> document.write(Date()); </script> 2,改变 HTML 内容 <script> doc ...
- ABAP 日期栏函数
在SZC这个中有很多日期函数可以研究借鉴 ABAP - 日期格式转换 现在提供以下一些日期格式转换的函数: Below are several FMs which can be used to c ...
- github for unity
- iOS 设备获取唯一标识符汇总
在2013年3月21日苹果已经通知开发者,从2013年5月1日起,访问UIDID的应用将不再能通过审核,替代的方案是开发者应该使用“在iOS 6中介绍的Vendor或Advertising标示符”. ...
- linux 中mmap的用法
函数:void *mmap(void *start,size_t length,int prot,int flags,int fd,off_t offsize); 参数start(dst):指向欲映射 ...