Replacing Elements
Replacing Elements
You have an array a1,a2,…,an. All ai are positive integers.
Input
The first line contains a single integer t (1≤t≤2000) — the number of test cases.
The second line contains n integers a1,a2,…,an (1≤ai≤100) — the array a.
In the second test case, all ai are already less or equal than d=4.
题解
直接找出最小的两个,判断是否<=d就行,还有一种情况是最小的两个>d但是所有都<=d
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{ll n,q,d;ll cb[1000],cb2[1000];cin>>n;for(ll i=1 ; i<=n ; i++){memset(cb2,0,sizeof(cb2));cin>>q>>d;for(ll j=1 ; j<=q ; j++){cin>>cb[j];}int cnt = 0;for(ll j=1 ; j<=q ; j++){for(ll k=j+1 ; k<=q ; k++){if(cb[j]+cb[k] <= d){cnt = 1;break;}}}if(cnt == 0){int qq = 1;for(ll j=1 ; j<=q ; j++){if(cb[j]>d){qq = 0;}}if(qq){cnt = 1;}}if(cnt == 1){cout<<"YES\n";}else{cout<<"NO\n";}}}
Replacing Elements相关推荐
- Replacing Elements (CodeForces - 1473A)
Replacing Elements You have an array a1,a2,-,an. All ai are positive integers. In one step you can c ...
- Angular component的一个例子
官网:https://angular.io/guide/architecture-components Before a view is displayed, Angular evaluates th ...
- python设置堆大小_Python中的堆问题
Heap in python 堆(英语:Heap)是计算机科学中一类特殊的数据结构的统称.堆通常是一个可以被看做一棵树的数组对象.在队列中,调度程序反复提取队列中第一个作业并运行,因为实际情况中某些时 ...
- 《泛型编程与stl》
以下是STL六大组件(componments): adapters 配接器 用来修饰其他组件.包括iterator adapters.function adapters.container ada ...
- 【CF比赛】Educational Codeforces Round 102 (Rated for Div. 2)
题目来源 Educational Codeforces Round 102 (Rated for Div. 2) A. Replacing Elements 只要判断最大值是否小于等于d,或者第一个值 ...
- Mixed Finite Elements for Variational Surface Modeling
paper source { formula 5 LB=12<v,v>Ω0+<λ,Δu−v>Ω0=12<v,v>Ω0−<λ,v>Ω0+<λ,Δu& ...
- AtCoder Beginner Contest 171 D - Replacing
D - Replacing Time Limit: 2 sec / Memory Limit: 1024 MB Score : 400400 points Problem Statement You ...
- vue/require-v-for-key]Elements in iteration expect to have ‘v-bind:key‘ directives
报错内容:[vue/require-v-for-key]Elements in iteration expect to have 'v-bind:key' directives.解决:加上v-bind ...
- Robotium todolist.test.elements
2019独角兽企业重金招聘Python工程师标准>>> ElementsEditToDoItemActivity package com.example.todolist.test. ...
最新文章
- SQL Server 数据库备份
- python迭代器面试题_Python面试题之生成器/迭代器
- 金山电子表格金山电子表格为何会死机?
- mysql 分区指定路径_[数据库]MySQL 指定各分区路径
- HDU-1170的解题报告
- Spring核心(ioc控制反转)
- ios点击推送闪退_苹果推送iOS 14.2 beta 1:千万别更新,大批应用闪退
- JavaScript每日学习日记(2)
- 173. 二叉搜索树迭代器/94. 二叉树的中序遍历/145. 二叉树的后序遍历/98. 验证二叉搜索树
- java登陆session用法_java中session用法
- [转].net中的认证(authentication)与授权(authorization)
- 机器学习(11): FP-growth算法 小结及实验
- 网页中使用iconfont图标
- Flutter 启动页 消除白屏
- 唯一分解之Pollard-Rho算法
- 一文搞懂考研数列极限问题(概念/计算/证明)史上最强/最全总结
- 10min快速了解k8s基础
- SRS流媒体服务器——服务器读取RTMP推流数据
- 架构设计文档提纲简描
- py sel采集部署linux报错
热门文章
- 人工智能Java SDK:声纹识别
- 友宝:掘金生活物联网
- WebStorm下载及破解
- 用Python爬取微信好友头像,才知道好友都是这样的人
- 截止频率计算公式wc_已知低通滤波器的传递函数是G(s)=(G0*Wc)/(s+Wc),截止频率不超过2HZ,怎么求?...
- 一文带你深入了解Linux IIO 子系统
- opencv remap matlab,C++ Opencv remap()重映射函数详解及使用示例
- GraphicsLab Project之基于物理的着色系统(Physical based shading) - 基于图像的光照(Image Based Lighting)(Diffuse篇)
- Python0019 音频处理(二).wav文件
- 行列式【线性代数系列(一)】