博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #307 (Div. 2)
阅读量:7222 次
发布时间:2019-06-29

本文共 4906 字,大约阅读时间需要 16 分钟。

A. GukiZ and Contest
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest.

In total, n students will attend, and before the start, every one of them has some positive integer rating. Students are indexed from 1 to n. Let's denote the rating of i-th student as ai. After the contest ends, every student will end up with some positive integer position. GukiZ expects that his students will take places according to their ratings.

He thinks that each student will take place equal to . In particular, if student A has rating strictly lower then student BA will get the strictly better position than B, and if two students have equal ratings, they will share the same position.

GukiZ would like you to reconstruct the results by following his expectations. Help him and determine the position after the end of the contest for each of his students if everything goes as expected.

Input

The first line contains integer n (1 ≤ n ≤ 2000), number of GukiZ's students.

The second line contains n numbers a1, a2, ... an (1 ≤ ai ≤ 2000) where ai is the rating of i-th student (1 ≤ i ≤ n).

Output

In a single line, print the position after the end of the contest for each of n students in the same order as they appear in the input.

Examples
input
3 1 3 3
output
3 1 1
input
1 1
output
1
input
5 3 5 3 4 5
output
4 1 4 3 1
Note

In the first sample, students 2 and 3 are positioned first (there is no other student with higher rating), and student 1 is positioned third since there are two students with higher rating.

In the second sample, first student is the only one on the contest.

In the third sample, students 2 and 5 share the first position with highest rating, student 4 is next with third position, and students 1 and 3are the last sharing fourth position.

 问你一个数排第几

#include
using namespace std;int a[2005];int main(){ int n; cin>>n; for(int i=0;i
>a[i]; int s=1; for(int j=0;j
a[0])s++; printf("%d",s); for(int i=1;i
a[i])s++; printf(" %d",s);} return 0;}

直接这样枚举也能过,所以,sort的也能过吧

#include
using namespace std;int a[2005],b[2005];int main(){ int n; cin>>n; for(int i=0;i
>a[i]; copy(a,a+n,b); sort(b,b+n); cout<

完美,直接upper_bound美滋滋

B. ZgukistringZ
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one.

GukiZ has strings ab, and c. He wants to obtain string k by swapping some letters in a, so that k should contain as many non-overlapping substrings equal either to b or c as possible. Substring of string x is a string formed by consecutive segment of characters from x. Two substrings of string x overlap if there is position i in string x occupied by both of them.

GukiZ was disappointed because none of his students managed to solve the problem. Can you help them and find one of possible strings k?

Input

The first line contains string a, the second line contains string b, and the third line contains string c (1 ≤ |a|, |b|, |c| ≤ 105, where |s| denotes the length of string s).

All three strings consist only of lowercase English letters.

It is possible that b and c coincide.

Output

Find one of possible strings k, as described in the problem statement. If there are multiple possible answers, print any of them.

Examples
input
aaa a b
output
aaa
input
pozdravstaklenidodiri niste dobri
output
nisteaadddiiklooprrvz
input
abbbaaccca ab aca
output
ababacabcc
Note

In the third sample, this optimal solutions has three non-overlaping substrings equal to either b or c on positions 1 – 2 (ab), 3 – 4 (ab), 5 – 7 (aca). In this sample, there exist many other optimal solutions, one of them would be acaababbcc.

给定A,B,C串,其中A串(可能)包含B或C串,现在可以任意变换A串的位置,使A串中包含B串,C串的总个数最大。

所以贪心下啊,统计字母个数

#include 
using namespace std;char a[100100],b[100100],c[100100];int A[30],B[30],C[30],S[30];int main() { cin>>a>>b>>c; int len=strlen(a); for(int i=0; i
S[j]) { ok=0; break; } S[j]-=B[j]*i; } if(!ok) continue; int t=1001000; for(int j=0; j<26; j++) { if(C[j]==0) continue; t=min(t,S[j]/C[j]); } if(t+i>ans) { ans=t+i; x=i; y=t; } } for(int i=0; i

 

转载于:https://www.cnblogs.com/BobHuang/p/7265773.html

你可能感兴趣的文章
Python字符编码详解
查看>>
Android开发 Firebase动态链接打开APP
查看>>
基于 HTML5 Canvas 的 3D 模型贴图问题
查看>>
让技术不要成为“背锅侠”!
查看>>
dubbo源码分析系列——dubbo的SPI机制源码分析
查看>>
表格单元格td设置宽度无效的解决办法
查看>>
防止视频资源被下载
查看>>
都是并发惹的祸
查看>>
eclipse实现JavaWeb项目 增量打包
查看>>
面试题系列一之 程序生命周期
查看>>
设计模式——观察者模式:气象监测应用
查看>>
NSUserDefaults简介及如何使用 NSUserDefaults 存储自定义对象
查看>>
IntelliJ IDEA搭建SpringBoot
查看>>
深入浅出iOS事件机制
查看>>
hadoop理解
查看>>
Oracle——18用户、角色和权限信息的视图总结
查看>>
WordPress 中的 Debug 模式(调试模式)
查看>>
node下使用express框架,ejs模板引擎
查看>>
搜索:文本的匹配算法
查看>>
Fedora 17 LibreOffice 办公套件的安装与汉化
查看>>