当前位置:网站首页>The second blog, novice on the road, intensive training is very rich
The second blog, novice on the road, intensive training is very rich
2021-09-15 05:07:47 【lhclqslove】
Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has.
Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number.
Help Igor find the maximum number he can write on the fence.
The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105).
Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1.
5
5 4 3 2 1 2 3 4 5
- 1.
- 2.
55555
- 1.
2
9 11 1 12 5 8 9 10 6
- 1.
- 2.
33
- 1.
0
1 1 1 1 1 1 1 1 1
- 1.
- 2.
-1
- 1.
brief introduction : I'll give you the numbers first v, Show the value you have , Then I'll give you a sequence a[9] Means you want to write 1 To 9 The cost of these figures . Ask the maximum you can write ;
Answer key : First, find the length of the maximum value with the minimum cost , Then greedily take the maximum value of each digit ;
The code is as follows :
#include <stdio.h> #include <algorithm> #include <string.h> #include<iostream> #define ll long long using namespace std; const int maxn=1e5+5; int a[10]; int b[maxn]; struct node { int id,pri; double xjb; bool operator <(const node a) { if(pri!=a.pri) return pri<a.pri; else return id>a.id; } }st[10]; int v; int main() { scanf("%d",&v); for(int i=1;i<=9;i++) { scanf("%d",&a[i]); st[i].id=i; st[i].pri=a[i]; st[i].xjb=double(i)/double(a[i]); } sort(st+1,st+10);//ll ans=0; bool flag=false; int t=v/st[1].pri; int tmp=v,sd=t; for(int i=0;i<t;i++) { for(int j=9;j>=1;j--) { if((sd-1)*st[1].pri+a[j]<=tmp) { cout<<j; sd--; tmp-=a[j]; flag=true; break; } } } if(flag)cout<<endl; else cout<<-1<<endl;
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
Topic link http://codeforces.com/contest/349/problem/B
版权声明
本文为[lhclqslove]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/09/20210909115113535k.html
边栏推荐
- Skyler's actual combat penetration notes (III) - Raven
- Provable safety
- J'ai ri toute la journée.
- Artefact de recherche d'aide - terminal distant en temps réel
- Continuous deployment tools Argo CD - use
- Continuous deployment tools Argo CD - install
- 字节大神强推千页PDF学习笔记,阿里Android面试必问
- 字节大神强推千页PDF学习笔记,【面试总结】
- 字节大牛耗时八个月又一力作,原理解析
- 字節大神强推千頁PDF學習筆記,【面試總結】
猜你喜欢
-
字節大神强推千頁PDF學習筆記,阿裏Android面試必問
-
Byte Big God Push thousand pages PDF Learning notes, [Summary of interview]
-
Le Grand Dieu des octets pousse des milliers de pages de notes d'apprentissage PDF, Ali Android interview must ask
-
A été abusé par la conception du système
-
Soul painter: cartoon illustration SSH
-
Serial | Internet of things framework serversuper tutorial - 6. Concurrent communication mode development and precautions
-
Restore openstack virtual machine using virtual machine backup software
-
swagger2 Illegal DefaultValue null for parameter type integer
-
Drive module company records
-
The revival of technological minimalism
随机推荐
- Octet Big Bull prend huit mois et travaille dur.
- Comment reconnaître la validité d'une adresse avec une machine à l'état fini?
- How to use cqrs to effectively cut the code base according to business functions?
- Lemmy - link aggregator of the federal universe
- Why is reddit so slow and unreliable| HackerNews
- DDD current engineering method portfolio - Kamil
- Supprimer l'avant - dernier noeud de la liste liée
- Septembre 2021 liste des bases de données nationales - Mo Tianlun: Dream poursuit oceanbase, opengauss anti - Super polardb à un autre niveau
- 直击 2021 苹果秋季发布会:iPhone 13 全系降价,苹果彻底放大招?
- Tous les votes!Le projet Open source de weizhong linkis entre dans l'incubation Apache
- Coinbase fell after disclosing regulatory inquiries about loan products
- 直擊 2021 蘋果秋季發布會:iPhone 13 全系降價,蘋果徹底放大招?
- Cliquez directement sur le lancement d'automne 2021 d'Apple: iPhone 13 réduit les prix de l'ensemble de la gamme, Apple agrandit complètement le mouvement?
- Web vulnerability - SQL
- Tom Cat received the attention letter from Shenzhen Stock Exchange: explain the relevance between the main products and the concept of meta universe
- 推荐一款写数学公式的神器。
- Échelle élastique personnalisée de l'autoscaler knative
- Ruishu information completed the C2 round of 300 million yuan financing and released new data security products
- How to automate security compliance using kubernetes?
- Recommande un artefact pour écrire des formules mathématiques.
- If the "Maginot defense line" fails, how to do a good job in container cloud security?
- Tdsql-a makes every effort to meet the needs of massive data real-time analysis
- Word document recovery software recommendations
- [cjson] cjson learning notes (II)
- [Questions d'entrevue à haute fréquence] À vous de choisir
- 企业级项目实战讲解,我总结了所有面试题,
- 字节跳动历年Android中高级面试题全收录,算法 分布式 微服务
- 字节跳动上千道精选面试题还不刷起来,webrtc音视频开发
- Pénétration du cache et Avalanche du cache
- Can I save multiple product SKU pictures on pinduoduo by computer?
- VIM configuring C + + development environment win10
- 字節跳動上千道精選面試題還不刷起來,webrtc音視頻開發
- Des milliers de questions d'entrevue sélectionnées n'ont pas encore ét é effacées.
- Les questions d'entrevue de niveau intermédiaire et avancé d'Android au fil des ans sont entièrement incluses, et l'algorithme est distribué microservice
- J'ai résumé toutes les questions d'entrevue.
- 字節跳動曆年Android中高級面試題全收錄,算法 分布式 微服務
- 【项目管理/PMP/PMBOK第六版/新考纲】纯干货!敏捷型/Stacey矩阵/vuca/敏捷宣言/冲刺/产品负责人/敏捷团队/敏捷教练/待办事项列表/迭代任务列表/可交付产品增量
- Capacity of the Gaussian Two-Way Relay Channel to Within 1/2 Bit
- 分布式session解决方案原理
- solid works繪制航模發動機