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

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

1056. Mice and Rice (25)PAT甲級

2019-11-14 12:41:15
字體:
來源:轉載
供稿:網友

傳送門

#include<stdio.h>#include<queue>using namespace std;#define MAX_N 1010struct mouse{ int weight; int rank;}mouse[MAX_N];queue<int >q;int main(){ int np,ng,order; scanf("%d%d",&np,&ng); for(int i=0;i<np;i++){ scanf("%d",&mouse[i].weight); } for(int i=0;i<np;i++){ scanf("%d",&order); q.push(order); } int num=np; int group; while(q.size()!=1){ if(num%ng==0) group=num/ng; else group=num/ng+1; for(int i=0;i<group;i++){ int max=q.front(); for(int j=0;j<ng;j++){ if(i*ng+j>=num) break; int front=q.front(); if(mouse[front].weight>mouse[max].weight){ max=front; } mouse[front].rank=group+1; q.pop(); } q.push(max); } num=group; } mouse[q.front()].rank=1; for(int i=0;i<np;i++){
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鹤峰县| 梓潼县| 临猗县| 阜阳市| 措美县| 上杭县| 淮安市| 苏尼特左旗| 陇川县| 萨迦县| 皋兰县| 通辽市| 清丰县| 内乡县| 嵊泗县| 张家界市| 大余县| 吉安县| 汪清县| 尼勒克县| 多伦县| 江北区| 秦安县| 公安县| 辽阳县| 海门市| 江孜县| 新巴尔虎右旗| 门源| 虎林市| 确山县| 莆田市| 沙雅县| 英超| 佛教| 五大连池市| 崇义县| 牟定县| 商都县| 高雄县| 社会|