国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

P1586 魔法照片

2019-11-14 11:03:42
字體:
來源:轉載
供稿:網友

題目描述

佳佳在n個人中把照片給k個人,關系好壞的程度為W[i]。按照從大到小的序號對10取模的值將這些人分為10類。求出加上額外權值以后,最終的權值最大的k個人,并輸出他們的編號。如果兩人的W[i]相同,編號小的優先。

樣例輸入

10 101 2 3 4 5 6 7 8 9 102 4 6 8 10 12 14 16 18 20

樣例輸出

10 9 8 7 6 5 4 3 2 1

思路

O(n log n) 模擬,排序;

var n,k,i:longint; a,b,c:array[0..30000] of longint;PRocedure qsort(l,r:longint);var p,t,m,j:longint;begin i:=l;j:=r; p:=a[(l+r) div 2]; m:=c[(l+r) div 2]; repeat while (a[i]>p)or((a[i]=p)and(c[i]<m)) do inc(i); while (a[j]<p)or((a[j]=p)and(c[j]>m)) do dec(j); if i<=j then begin t:=a[i];a[i]:=a[j];a[j]:=t; t:=c[i];c[i]:=c[j];c[j]:=t; inc(i); dec(j); end; until i>j; if i<r then qsort(i,r); if l<j then qsort(l,j);end;procedure init;begin readln(n,k); for i:=1 to 10 do read(b[i]); for i:=1 to n do read(a[i]);end;begin init; for i:=1 to n do c[i]:=i; qsort(1,n); for i:=1 to n do a[i]:=a[i]+b[(i-1) mod 10+1]; qsort(1,n); for i:=1 to k do write(c[i],' ');end.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东乡族自治县| 五常市| 金堂县| 泸水县| 台安县| 会东县| 勃利县| 防城港市| 白水县| 泰安市| 翁源县| 鲜城| 黄大仙区| 丰宁| 凌云县| 博爱县| 宝山区| 平遥县| 嘉义县| 小金县| 镇江市| 和静县| 平阳县| 八宿县| 历史| 鄂托克前旗| 崇义县| 万州区| 邢台县| 天镇县| 绥中县| 榆树市| 崇信县| 田林县| 山阴县| 舞阳县| 巴东县| 丰台区| 政和县| 吉木乃县| 阿城市|