当前位置:网站首页>1080 Graduate Admission (30 分)
1080 Graduate Admission (30 分)
2022-07-22 10:33:00 【学编程的蒟蒻】
1080 Graduate Admission (30 分)
思路有空更新
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct node{
int id, ge, gi, r, admit;
double avg;
int ch[10];
}a[40050];
int b[150];
vector<int> v[150];
bool cmp(node x, node y) {
if(x.avg != y.avg)
return x.avg > y.avg;
else
return x.ge > y.ge;
}
int main() {
int n, m, k;
cin >> n >> m >> k;
for(int i = 0; i < m; ++i)
cin >> b[i];
for(int i = 0; i < n; ++i){
cin >> a[i].ge >> a[i].gi;
for(int j = 0; j < k; ++j)
cin >> a[i].ch[j];
a[i].id = i, a[i].avg = (a[i].ge + a[i].gi) / 2.0;
}
sort(a, a + n, cmp);
for(int i = 0; i < n; ++i){
if(a[i].avg != a[i - 1].avg)
a[i].r = i;
else{
if(a[i].ge == a[i - 1].ge)
a[i].r = a[i - 1].r;
else
a[i].r = i;
}
for(int j = 0; j < k; ++j){
int c = a[i].ch[j];
if(b[c] > 0) {
a[i].admit = c;
v[c].push_back(a[i].id);
b[c]--;
break;
}
else {
int f = 0;
for(int t = i - 1; a[t].r == a[i].r && t >= 0; t--){
if(a[t].admit == c){
a[i].admit = c;
v[c].push_back(a[i].id);
f = 1; break;
}
}
if(f) break;
}
}
}
for(int i = 0; i < m; ++i){
sort(v[i].begin(), v[i].end());
for(int j = 0; j < v[i].size(); ++j)
cout << v[i][j] << " \n"[j == v[i].size() - 1];
if(v[i].size() == 0) printf("\n");
}
}
边栏推荐
- Redis accesses JSON data
- LeetCode103——zigzagLevelOrder of binary tree
- YOLO v1、v2、v3
- 类模板剖析
- Common tools for data development - regular sending of query results email
- Pre training weekly 39: deep model, prompt learning
- 机器学习入门:支持向量机-6
- What is the meaning of DNS hijacking, the principle of DNS hijacking and several solutions
- What should I do after the domain name of website security is hijacked and the domain name is hijacked!!!
- Kubernets原理分解
猜你喜欢
LeetCode146——LRU Cache——DS Design
SSM框架整合
dns被劫持了怎么处理 5种方法教你处理
LeetCode0003——longest substring without repeating characters——Sliding Window
她力量系列五丨朱海一:以人为本,构建 AI 价值观
进程的互斥、同步
Dense Passage Retrieval for Open-Domain Question Answering笔记
没有人知道TikTok的最新流行产品Pink Sauce中含有什么成分
专访Women in AI学者黄惠:绘图形之梦,寻突破之门
What are the ways for Baidu homepage to be hijacked by TN? There are two ways to solve Baidu hijacking
随机推荐
7-3 Size of Military Unit (25 分)
How to deal with DNS hijacking, DNS hijacking, and DNS hijacking solutions
信号降噪方法
Spark data search
Typora download and simple use tutorial
What are the definitions and principles of domain name hijacking and the solutions to domain name hijacking
LeetCode0003——longest substring without repeating characters——Sliding Window
LeetCode160 & LeetCode141——double pointers to solve the linked list
Mutual exclusion and synchronization of processes
Introduction to elastic search: Restful advanced query operations (IX)
What are the common ways for websites to be hacked and hijacked? What are the DNS hijacking tools?
LeetCode32——next permutation
Linux下安装mysql
Leetcode0002——Add Two Numbers——Linked List
Classic cases of semaphore synchronization and mutual exclusion
The database is encapsulated by queryrunner simulation
LeetCode912——sort an array—— quick sort algorithm
flask 跨域
Dense Passage Retrieval for Open-Domain Question Answering笔记
On the horizontal trigger and edge trigger of epoll