当前位置:网站首页>Acwing: Game 60 of the week
Acwing: Game 60 of the week
2022-07-19 03:50:00 【Hello_ Ä】
AcWing: The first 60 Weekly match
4494. having dinner - AcWing Question bank
If n And less than or equal to m and k Namely yes, The rest are no.
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<numeric>
#include<string>
#include<string.h>
#include<iterator>
#include<map>
#include<unordered_map>
#include<stack>
#include<list>
#include<queue>
#include<iomanip>
#include<bitset>
#define endl '\n'
#define int ll
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll>PII;
const int N = 10, MOD = 1e9 + 7;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n,m,k;
cin>>n>>m>>k;
if(n<=m&&n<=k)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}
4495. Array operation - AcWing Question bank
Find the smallest decimal in the array , We can use small root piles , Output the number at the top of the small root heap each time .
As for each number output, if we subtract all the numbers of the group, it will obviously timeout . But we don't really have to subtract the numbers in each group , We use a variable x Record the number of outputs , For the initial 0, After outputting one number at a time, add that number to x On , Then when the subsequent number is output , All minus x Then the output ( We don't really need to reduce the number of root piles ), In this way, you can subtract all the numbers in the array x 了 .
Note that if the number at the top of the small root heap decreases x After equal to 0, Then pop up this number , Until the heap is empty or the number at the top of the small root heap decreases x Later not 0 that will do . If it is empty, output directly 0.
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<numeric>
#include<string>
#include<string.h>
#include<iterator>
#include<map>
#include<unordered_map>
#include<stack>
#include<list>
#include<queue>
#include<iomanip>
#include<bitset>
#define endl '\n'
#define int ll
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll>PII;
const int N = 10, MOD = 1e9 + 7;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n,m;
cin>>n>>m;
priority_queue<int, vector<int>, greater<int>>que;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
que.push(x);
}
int x=0;
while(m--)
{
while(!que.empty()&&que.top()-x==0)que.pop();
if(que.empty())cout<<0<<endl;
else
{
cout<<que.top()-x<<endl;
x+=que.top()-x;
}
}
return 0;
}
4496. Eat fruit - AcWing Question bank
Set a two-dimensional dynamic transfer array f,f[i] [j] To i Until students , Yes j Students have different plans from the students on his left f[i] [j], initial f[1] [0]=m.
If our current classmate takes the same fruit as our last classmate , Then the number of schemes should be f[i-1] [j], And if it's different , If the last student took it 1 Fruit No , We can take 2m Fruit No , If you take 2 Fruit No , We can take 1 Number and 3m Fruit No . That is, no matter which fruit the last student took , We can all take the rest m-1 Fruit , Then the number of schemes is f[i-1] [j-1]*(m-1). So the state transfer equation is :
- The fruit of the current student is the same as that of the previous student :f[i] [j]=f[i-1] [j].
- The current student and the previous student have different fruit numbers :f[i] [j]=f[i-1] [j-1] *(m-1).
The final answer is f[n] [k].
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<numeric>
#include<string>
#include<string.h>
#include<iterator>
#include<map>
#include<unordered_map>
#include<stack>
#include<list>
#include<queue>
#include<iomanip>
#include<bitset>
#define endl '\n'
#define int ll
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll>PII;
const int N = 10, MOD = 1e9 + 7;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n,m;
cin>>n>>m;
priority_queue<int, vector<int>, greater<int>>que;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
que.push(x);
}
int x=0;
while(m--)
{
while(!que.empty()&&que.top()-x==0)que.pop();
if(que.empty())cout<<0<<endl;
else
{
cout<<que.top()-x<<endl;
x+=que.top()-x;
}
}
return 0;
}
边栏推荐
- 程序分析与优化 - 11 多分支分析
- A robust deformation convolution neural network image denoising
- DataX DorisWriter 插件文档
- Frequency school and Bayes school
- Web semantics (emphasis tag EM italic) (emphasis tag strong bold) (custom list: DL, DT, DD)
- 【MySQL】在云服务器上安装配置mysql,并使用IDEA连接
- 为什么越来越多人开始选择过“低配生活”?
- LeetCode 931:下降路径最小和
- 自然语言处理 知识点积累
- HRNet
猜你喜欢

运算符、赋值语句、结构说明语句

Application of MATLAB in linear algebra

Burpsuite2022.1 detailed installation steps include certificate installation

Derivation of PCA principal component analysis (dimension reduction) process

EfficientNet系列(1): EfficientNetV2网络详解

HRNet

Boston house price analysis assignment summary

Fisher linear discriminant analysis

v-for 中 key 的作用

TS的使用案例——贪吃蛇
随机推荐
正畸学分支和工具
Sword finger offer 59 - ii Maximum value of queue
2022电工杯:5G 网络环境下应急物资配送问题(优化)
掩饰性治疗
kubernetes学习之持久化存储StorageClass(4)
Chapter I Introduction
Hcip Experiment 5
AI 之 OpenCvSharp 大图找小图(案例版)
剑指 Offer 60. n个骰子的点数
AI 之 OpenCvSharp 大圖找小圖(案例版)
NIM boben problem
HCIP第五天笔记
Underline shortcut
初识ESP8266(二)————搭建网络服务器实现远程控制
线程的私有存储空间
Work fishing clock simulator wechat applet source code
v-for 中 key 的作用
【LeetCode】558. 四叉树交集
SparkCore核心设计:RDD,220716,
当 mysql 表从压缩表变成普通表会发生什么?