【想法题】Knot Puzzle @AtCoder Grand Contest 002 C/upcexam5583
时间限制: 2 Sec 内存限制: 256 MB
题目描述
We have N pieces of ropes, numbered 1 through N. The length of piece i is ai.
At first, for each i(1≤i≤N−1), piece i and piece i+1 are tied at the ends, forming one long rope with N−1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:
Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N−1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
Constraints 2≤N≤105 1≤L≤109 1≤ai≤109 All input values are integers.
输入
The input is given from Standard Input in the following format:
N L a1 a2 … an
输出
If it is not possible to untie all of the N−1 knots,
print Impossible.
样例输入
3 50
样例输出
Possible
提示
If the knot 1 is untied first, the knot 2 will become impossible to untie.
题目大意是给你n根绳子通过打结的方式首尾相接成一根绳子,要你解开这个绳子上所有的结,但你每次只能选一根长度大于L的绳子解开其上的一个结。
如果我们把用来组成长绳的n个绳子称作绳元
只要有两个相邻的绳元长度大于L,就可以以这两个绳元为中心从两端解开整根绳子。
#define IN_PC() freopen("C:\\Users\\hz\\Desktop\\in.txt","r",stdin)
#define OUT_PC() freopen("C:\\Users\\hz\\Desktop\\out.txt","w",stdout)
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int a[maxn];
int main()
{
// IN_PC();
// OUT_PC();
int n,L;
cin>>n>>L;
for(int i=0;i<n;i++){
scanf("%d",a+i);
}
int flag = 0;
for(int i=1;i<n;i++){
if(a[i-1]+a[i]>=L)flag = 1;
}
printf("%s\n",flag?"Possible":"Impossible");
return 0;
}
【想法题】Knot Puzzle @AtCoder Grand Contest 002 C/upcexam5583的更多相关文章
- AtCoder Grand Contest 002
AtCoder Grand Contest 002 A - Range Product 翻译 告诉你\(a,b\),求\(\prod_{i=a}^b i\)是正数还是负数还是零. 题解 什么鬼玩意. ...
- AtCoder Grand Contest 002 F:Leftmost Ball
题目传送门:https://agc002.contest.atcoder.jp/tasks/agc002_f 题目翻译 你有\(n*k\)个球,这些球一共有\(n\)种颜色,每种颜色有\(k\)个,然 ...
- Atcoder Grand Contest 002 F - Leftmost Ball(dp)
Atcoder 题面传送门 & 洛谷题面传送门 这道 Cu 的 AGC F 竟然被我自己想出来了!!!((( 首先考虑什么样的序列会被统计入答案.稍微手玩几组数据即可发现,一个颜色序列 \(c ...
- AtCoder Grand Contest 002 D - Stamp Rally
Description We have an undirected graph with N vertices and M edges. The vertices are numbered 1 thr ...
- [Atcoder Grand Contest 002] Tutorial
Link: AGC002 传送门 A: …… #include <bits/stdc++.h> using namespace std; int a,b; int main() { sca ...
- AtCoder Grand Contest 002 (AGC002) F - Leftmost Ball 动态规划 排列组合
原文链接https://www.cnblogs.com/zhouzhendong/p/AGC002F.html 题目传送门 - AGC002F 题意 给定 $n,k$ ,表示有 $n\times k$ ...
- AtCoder Grand Contest 002题解
传送门 \(A\) 咕咕 int main(){ cin>>a>>b; if(b<0)puts(((b-a+1)&1)?"Negative": ...
- AtCoder Grand Contest 012
AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大 ...
- AtCoder Grand Contest 005
AtCoder Grand Contest 005 A - STring 翻译 给定一个只包含\(ST\)的字符串,如果出现了连续的\(ST\),就把他删去,然后所有位置前移.问最后剩下的串长. 题解 ...
随机推荐
- Oracle Client(客户端) 安装与配置
因为工作需要,需要通过本地oracle客户端将数据导入到远程服务器上的oracle数据库中.从csdn下了很多oracle客户端,都是属于精简版,缺少imp.exe文件,造成无法导入数据.所以最终从o ...
- 关闭PHP的opcache缓存
1.使用phpinfo();查看配置信息 2.搜索Additional .ini files parsed 3.查看opcache安装目录 4.打开文件将 opcache.enable=1 改成 ...
- gradle根据不同渠道设置不同的开屏启动页
需求:根据不同渠道,app的开屏启动页不一样 思路:因为app的启动页是在清单文件配置的,而清单文件最后是要和main里面的清单文件合并的,所以每个渠道都要配一个清单文件,在里面设置 然后在Andro ...
- Codeforces 852G Bathroom terminal 【Trie树】
<题目链接> 题目大意: 现在给定出n个字符串,并且进行m此询问,每次询问给出一个匹配串,每次询问都给出该匹配串能够匹配的字符串个数(题目只出现字符'a'~'e').'?'可以看成任意字符 ...
- 在web项目中搭建一个spring mvc + spring + mybatis的环境
介绍:本文中示范搭建一个ssm环境的框架:使用流程就是客户端通过http请求访问指定的接口,然后由服务器接受到请求处理完成后将结果返回. 本项目请求流程细节介绍:由客户端请求到指定的接口,这个接口是个 ...
- F - Tmutarakan Exams URAL - 1091 -莫比乌斯函数-容斥 or DP计数
F - Tmutarakan Exams 题意 : 从 < = S 的 数 中 选 出 K 个 不 同 的 数 并 且 gcd > 1 .求方案数. 思路 :记 录 一 下 每 个 数 的 ...
- Linux 系统分级及root权限相关
单用户模式修改用户密码 救援模式 让我们先来了解一下linux的运行步骤 1. Linux系统引导的顺序掌握Linux系统引导的顺序:BIOSMBRKernelinit其中,BIOS的工作是检查计算机 ...
- opencv3 学习笔记(一)
1.cv2.imread(path,cv2.IMREAD_ANYCOLOR) IMREAD_ANYCOLOR=4(全彩模式)/IMREAD_GRAYSCALE=0(灰度模式)2.cv2.imwrite ...
- 《动物世界》的剪刀石头布 HDU --- 6418
题目连接: https://vjudge.net/problem/1812686/origin emmm 这一题的资料来自<动物世界>这一个李易峰演的电影.. 主要的思路就是概率,但是会牵 ...
- Python中的iteritems()和items()
我用的是Python3.6 在Python3.x中,iteritems() 和 viewitems() 这两个方法都已经废除了,用 items()替换iteritems() ,for循环来遍历出来.