当前位置:网站首页>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;
}
边栏推荐
- Shell Scripting tips
- DevOps及DevOps常用的工具介绍
- 一周精彩内容分享(第13期)
- Grep actually uses ps/netstat/sort
- Best practice | using Tencent cloud AI character recognition to realize enterprise qualification certificate recognition
- [golang] before method of time type in golang
- [QNX hypervisor 2.2 user manual]9.2 CmdLine
- Import the data in MariaDB into columnstore
- Easy to use example
- Leetcode 257. 二叉树的所有路径
猜你喜欢

链表——142. 环形链表 II

【10】 Teamwork and cross team collaboration

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

Depth first search and breadth first search of Graphs

2022, the average salary of the soft tester, after reading it, I was instantly cool

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

JMeter if controller

Lanqiao cup provincial training camp - stack and recursion
](/img/fd/e12f43e23e6ec76c2b44ce7813e204.png)
运算放大器 —— 快速复苏笔记[贰](应用篇)

Paging query of employee information of black maredge takeout
随机推荐
哈希——1. 两数之和——有人白天相爱,有人夜里看海,有人力扣第一题都做不出来
[golang] before method of time type in golang
【Markdown语法高级】让你的博客更精彩(四:设置字体样式以及颜色对照表)
stream流
Linked list - Sword finger offer interview question 02.07. linked list intersection
07 [use of path and files classes]
Import the data in MariaDB into columnstore
视频回放 | 如何成为一名优秀的地学和生态学领域的国际期刊审稿人?
【10】 Teamwork and cross team collaboration
The third day of hcip mGRE experiment
Share the typora tool
Cgo+gsoap+onvif learning summary: 9. Go and C conduct socket communication and onvif protocol processing
Online customer service chat system source code_ Beautiful and powerful golang kernel development_ Binary operation fool installation_ Construction tutorial attached
How to choose sentinel vs. hystrix current limiting?
源码分析Sentry用户行为记录实现过程
这才是开发者神器正确的打开方式!
What is cloud native? Why is cloud native technology so popular?
Ctfshow ThinkPHP topic 1
tcp 服务端接收数据处理思路梳理,以及select: Invalid argument报错 笔记
Hcip OSPF interface network type experiment day 4