当前位置:网站首页>L1-049 天梯赛座位分配
L1-049 天梯赛座位分配
2022-07-24 11:39:00 【Cod_ing】
一道稍微有点绕的模拟题,看了本站上其他同志的博客,感觉还是在下的比较简单直观
#include<iostream>
#include<vector>
using namespace std;
int A[105];
vector<int> ans[105];
int main() {
int N;
cin >> N;
int sum = 0;
for (int i = 0; i < N; i++) {
cin >> A[i];
A[i] *= 10; //每个学校可以容纳的人数
sum += A[i]; //整体可以容纳的人数
}
int num = 0;
int tag = -1; //标记上一位选手的学校
for (int i = 0; i < sum; i++) {
//对每个选手的编号进行分配
for (int j = 0; j < N; j++) {
//每个学校依次分配一个编号
if (A[j]>0) {
//A[j]==0表示此学校的所有选手编号已分配
if (tag != j) num++; //学校不同,那就依次
else num += 2; //学校相同,那就隔一位入座
ans[j].push_back(num);
tag=j;
A[j]--;
}
}
}
for (int i = 0; i < N; i++) {
cout << "#" << i + 1 << endl;
for (int j = 0; j < ans[i].size(); j++) {
cout << ans[i][j];
if (j % 10 == 9) cout << endl;
else cout << " ";
}
}
return 0;
}
边栏推荐
- Operational amplifier - Notes on rapid recovery [II] (application)
- C language programming code
- Linked list - 142. Ring linked list II
- 网络爬虫之短信验证
- Nodejs CTF Foundation
- Build resume editor based on Nocode
- Types and history of bugs in it circle
- Hcip OSPF interface network type experiment day 4
- 字符串——344.反转字符串
- RRPN:Arbitrary-Oriented Scene Text Detection via Rotation Proposals
猜你喜欢

HDU5667 Sequence

Types and history of bugs in it circle

链表——剑指offer面试题 02.07. 链表相交

使用Prometheus+Grafana实时监控服务器性能

6k+ star, a deep learning code base for Xiaobai! One line of code implements all attention mechanisms!

The third day of hcip mGRE experiment

Hcip OSPF interface network type experiment day 4

Two important laws about parallelism

SSH跨平台终端工具tabby推荐

视频回放 | 如何成为一名优秀的地学和生态学领域的国际期刊审稿人?
随机推荐
Svn server and client installation (Chinese package) and simple use
Lanqiao cup provincial training camp - commonly used STL
Semaphore details
Semaphore详解
1184. 公交站间的距离 : 简单模拟题
Operational amplifier - Notes on rapid recovery [1] (parameters)
Exceptions about configuring Postgres parameters
Remember to optimize my personal blog once
MOS tube - Notes on rapid recovery application (I) [principle]
RetinaNet:Focal Loss for Dense Object Detection
[QNX hypervisor 2.2 user manual]9.2 CmdLine
Leetcode 257. 二叉树的所有路径
Use of getchar
Types and history of bugs in it circle
JVM visualvm: multi hop fault handling tool
20000 words detailed explanation, thoroughly understand es!
MOS管 —— 快速复苏应用笔记(壹)[原理篇]
HCIP OSPF接口网络类型实验 第四天
Shell script "< < EOF" my purpose and problems
[deserialization vulnerability-02] principle test and magic method summary of PHP deserialization vulnerability