时间限制: 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的更多相关文章

  1. AtCoder Grand Contest 002

    AtCoder Grand Contest 002 A - Range Product 翻译 告诉你\(a,b\),求\(\prod_{i=a}^b i\)是正数还是负数还是零. 题解 什么鬼玩意. ...

  2. AtCoder Grand Contest 002 F:Leftmost Ball

    题目传送门:https://agc002.contest.atcoder.jp/tasks/agc002_f 题目翻译 你有\(n*k\)个球,这些球一共有\(n\)种颜色,每种颜色有\(k\)个,然 ...

  3. Atcoder Grand Contest 002 F - Leftmost Ball(dp)

    Atcoder 题面传送门 & 洛谷题面传送门 这道 Cu 的 AGC F 竟然被我自己想出来了!!!((( 首先考虑什么样的序列会被统计入答案.稍微手玩几组数据即可发现,一个颜色序列 \(c ...

  4. 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 ...

  5. [Atcoder Grand Contest 002] Tutorial

    Link: AGC002 传送门 A: …… #include <bits/stdc++.h> using namespace std; int a,b; int main() { sca ...

  6. AtCoder Grand Contest 002 (AGC002) F - Leftmost Ball 动态规划 排列组合

    原文链接https://www.cnblogs.com/zhouzhendong/p/AGC002F.html 题目传送门 - AGC002F 题意 给定 $n,k$ ,表示有 $n\times k$ ...

  7. AtCoder Grand Contest 002题解

    传送门 \(A\) 咕咕 int main(){ cin>>a>>b; if(b<0)puts(((b-a+1)&1)?"Negative": ...

  8. AtCoder Grand Contest 012

    AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大 ...

  9. AtCoder Grand Contest 005

    AtCoder Grand Contest 005 A - STring 翻译 给定一个只包含\(ST\)的字符串,如果出现了连续的\(ST\),就把他删去,然后所有位置前移.问最后剩下的串长. 题解 ...

随机推荐

  1. Multi-Fiber Networks for Video Recognition (MFNet)

    Motivation:减少时空网络的计算量,保持视频分类精度的基础上,使速度尽可能接近对应网络的2D版本. 为此提出 Multi-Fiber 网络,将复杂网络拆分成轻量网络的集成,利用 fibers ...

  2. 1.RN环境搭建,创建项目,使用夜神模拟调试

    1.环境搭建(Yarn.React Native 的命令行工具(react-native-cli)) npm install -g yarn react-native-cli 具体参考 参见官方(中文 ...

  3. WINDOWS 2008Server 配置nginx 反向代理服务器 安装成服务

    本案例有用过可行 反向代理就是是网站通过一台机器发布到公网,客户访问的时候是直接访问那台代理机器的,然后通过那台机器才访问到内网网站.   0.先要在域名官网上面配置域名对应的IP地址,然后要在自己路 ...

  4. eclipse发布后在tomcat下没有文件夹,服务器的Server locations不能修改

    主要是因为Server locations中的deploy路径不正确,要修改这个路径,需要移除服务器中的所有项目,然后点击清空,这时再双击服务器,既可修改这个设置.

  5. python__int 部分内部功能介绍

    查看创建的对象的类型: age=18 print(type(age)) 结果: <class 'int'> x.bit_length():返回二进制的位数 Python中进制的转换: Py ...

  6. Flink应用开发-maven导入

    flink和spark类似,也是一种一站式处理的框架:既可以进行批处理(DataSet),也可以进行实时处理(DataStream) 使用maven导入相关依赖 <properties> ...

  7. BZOJ1856 [Scoi2010]字符串 数论

    原文链接http://www.cnblogs.com/zhouzhendong/p/8084577.html 题目传送门 - BZOJ1856 题意概括 找出由n个1,m个0组成的字符串,且任意前几个 ...

  8. hive启用压缩

    <property> <name>hive.exec.compress.intermediate</name> <value>true</valu ...

  9. Hadoop| MapperReduce02 框架原理

    MapReduce框架原理 MapReduce核心思想 1)分布式的运算程序往往需要分成至少2个阶段. 2)第一个阶段的MapTask并发实例,完全并行运行,互不相干. 3)第二个阶段的ReduceT ...

  10. 比特币源码分析--C++11和boost库的应用

    比特币源码分析--C++11和boost库的应用     我们先停下探索比特币源码的步伐,来分析一下C++11和boost库在比特币源码中的应用.比特币是一个纯C++编写的项目,用到了C++11和bo ...