One very well-known internet resource site (let's call it X) has come up with a New Year adventure. Specifically, they decided to give ratings to all visitors.
There are n users on the site, for each user we know the rating value he wants to get as a New Year Present. We know that user i wants to get at least ai rating units as a present.
The X site is administered by very creative and thrifty people. On the one hand, they want to give distinct ratings and on the other hand, the total sum of the ratings in the present must be as small as possible.
Help site X cope with the challenging task of rating distribution. Find the optimal distribution.
The first line contains integer n (1 ≤ n ≤ 3·105) — the number of users on the site. The next line contains integer sequencea1, a2, ..., an (1 ≤ ai ≤ 109).
Print a sequence of integers b1, b2, ..., bn. Number bi means that user i gets bi of rating as a present. The printed sequence must meet the problem conditions.
If there are multiple optimal solutions, print any of them.
3 5 1 1
5 1 2
1 1000000000
1000000000
题意:
给一个数N(1到300000),代表有N个数,随后给出N个数。分别是 a1 到 an ,ai 范围是 1 到 10^9。分配数字要求必须满足:
1.大于等于本身这个数;
2.分配后得的这个数字必须不同于其他所有的数;
3.分配所有数字后得出来的这些数的总和要求最小。
思路:
贪心。对 ai 进行由小到大排序,由小的值(并不是从原来的排序的顺序)开始重新赋值,更新的同时维护当前的最小值。
AC:
#include<cstdio> #include<algorithm> using namespace std; typedef struct { int val; //当前值 int num; //当前值的序号 }node; node no[300005]; int fin[300005]; //与当前值序号对应 int cmp(node a,node b) { return a.val<b.val; //由小到大排序 } int main() { int n,m = -1; scanf("%d",&n); for(int i = 1;i <= n;i++) { scanf("%d",&no[i].val); no[i].num = i; } sort(no + 1,no + 1 + n,cmp); for(int i = 1;i <= n;i++) { fin[no[i].num]=max(m+1,no[i].val); m=fin[no[i].num]; } for(int i = 1;i <= n;i++) { printf("%d",fin[i]); i == n ? printf("\n") : printf(" "); } return 0; }
相关推荐
ratings.csv
ratings200.dat
Laravel开发-user-ratings 将用户评级添加到Laravel 5.1雄辩模型中。
资源分类:Python库 所属语言:Python 资源全名:pinax_ratings-3.0.1-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
来自6000用户对4000多部电影的超100万条评论数据 MovieLens 1M Dataset Stable benchmark dataset. 1 million ratings from 6000 users on 4000 movies. Released 2/2003.
Mahout实践指南中的例子,有关推荐引擎的测试数据,包含movies.dat, ratings.dat, users.dat 和 README
采样的movielens数据集,一般用来推荐模型中的测试。标椎格式txt可以尝试下自己的新模型,这种数据一般用于有评分数据的模型,用于矩阵分解之类的模型。...推荐算法模型可以查看我的相关博文,关注即可。...
本数据集是movielens公开的数据集 不是完整版是关于评分的 主要的作用是配合我写的参数估计 python实践使用的
机器学习(数据分析)入门的案例数据 Users.csv,Books.csv,Book-Ratings.csv
movie_ratings NewDay的数据工程师招聘流程
yarn add react-native-ratings 要么 npm install --save react-native-ratings 用法 import { Rating , AirbnbRating } from 'react-native-ratings' ; const WATER_IMAGE = require ( './water.png' ) ...
Laravel开发-laravel-ratings Laravel额定功率发动机
目的:Sigma Ratings 是 AML 市场的新进入者,旨在减轻 AML 制度中的一些固有缺陷。 本文旨在检查这些缺陷,并询问 Sigma 能否在这个蓬勃发展的市场中取得成功。设计/方法论:本文基于一种规范性方法论,该方法论是...
docker build -t ratings . # Run MongoDB with initial data in database docker run -d --name mongodb -p 27017:27017 \ -v $( pwd ) /databases:/docker-entrypoint-initdb.d bitnami/mongodb:4.4.4-debian-10-...
Teacher efficacy and teacher competency ratings Prvchology in the Srhoolr Volume 22. July 1985 TEACHER EFFICACY AND TEACHER COMPETENCY RATINGS LANDA TRENTHAM, STEVEN SILVERN, A N D RICHARD ...
语言:English 打开网页后,只需单击扩展一次,然后将鼠标悬停在电影名称上,您将获得所有信息。 曾经花费数小时… 打开网页后,只需单击扩展一次,然后将鼠标悬停在电影名称上,您将获得所有信息。...
ratings, CakePHP的分级插件 的分级插件 你可以通过简单的增加评分组件给你的控制器评分,从而让你的评分达到 。 组件将自动加载 helper 和行为。这个插件的核心部分是附加到你的模型中的ratable行为。 大多数情况下...
new Import Ratings option Poweramp now exports/imports track ratings via m3u8 playlists new Network Stream Buffer option new Play as Next option new Bookmarks category Playlist for songs with the ...