当前位置:网站首页>Program design: l1-49 ladder race, allocation of seats (simulation), Buxiang pill hot
Program design: l1-49 ladder race, allocation of seats (simulation), Buxiang pill hot
2022-04-23 02:22:00 【Find a derivative first】
subject
The question : A little .
Ideas : It's numb , I have no brain . Don't wrap , It will be found that it is a matrix assignment problem ,100100 Of , There is only one school in the end .
Time complexity : O(100100)
Code :
#include<bits/stdc++.h>
using namespace std;
const int N = 102;
int n,m,k,T;
int s[N][N];
int a[N],b[N];
int mx = 0;
void solve()
{
cin>>n;
for(int i=0;i<n;++i) cin>>a[i],a[i]*=10,b[i] = a[i],mx = max(mx,a[i]);
int cnt = n;
int now = 1;
for(int j=0;j<mx;++j)
{
for(int i=0;i<n;++i)
{
if(a[i])
{
if(--a[i]==0) cnt--;
s[i][j] = now++;
if(cnt==1&&a[i]>0) now++;
}
}
}
for(int i=0;i<n;++i)
{
printf("#%d\n",i+1);
for(int j=1;j<=b[i];++j)
{
printf("%d",s[i][j-1]);
if(j%10==0) printf("\n");
else printf(" ");
}
}
}
signed main(void)
{
solve();
return 0;
}
版权声明
本文为[Find a derivative first]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230222217214.html
边栏推荐
- They are all intelligent in the whole house. What's the difference between aqara and homekit?
- LeetCode 349. Intersection of two arrays (simple, array) Day12
- Lighting LED of IAR embedded development stm32f103c8t6
- Network jitter tool clumsy
- 89 régression logistique prédiction de la réponse de l'utilisateur à l'image de l'utilisateur
- A simple and open source navigation website source code
- PTA: 浪漫倒影 [二叉树重建] [深度优先遍历]
- MySQL C language connection
- Introduction to esp32 Bluetooth controller API
- 001_redis设置存活时间
猜你喜欢
The usage and difference of * and & in C language and the meaning of keywords static and volatile
Kubernetes cluster installation based on Kirin SP10 server version
013_基于Session实现短信验证码登录流程分析
012_ Access denied for user ‘root‘@‘localhost‘ (using password: YES)
001_ Redis set survival time
世界读书日 | 技术人不要错过的好书(IT前沿技术)
New book recommendation - IPv6 technology and application (Ruijie version)
Want to experience homekit smart home? Why don't you take a look at this smart ecosystem
Introduction to esp32 Bluetooth controller API
leetcode:27. 移除元素【count remove小操作】
随机推荐
89 logistic regression user portrait user response prediction
006_ redis_ Jedis quick start
011_RedisTemplate操作Hash
day18--栈队列
php 2022年4月20面试题整理
Develop a chrome plug-in from 0 (2)
Shardingsphere broadcast table and binding table
World Book Day 𞓜 a good book that technicians should not miss (it cutting-edge technology)
每日一题(2022-04-21)——山羊拉丁文
【2019-CVPR-3D人体姿态估计】Fast and Robust Multi-Person 3D Pose Estimation from Multiple Views
Talk about current limiting
010_ StringRedisTemplate
Chinese scientists reveal a new mechanism for breaking through the bottleneck of rice yield
Use of push() and pop()
006_redis_jedis快速入门
JSP page nesting
006_redis_SortedSet类型
OJ daily practice - Finish
Introduction to micro build low code zero Foundation (lesson 2)
Synchronized lock and its expansion