时间限制: 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. POJ 1364 / HDU 3666 【差分约束-SPFA】

    POJ 1364 题解:最短路式子:d[v]<=d[u]+w 式子1:sum[a+b+1]−sum[a]>c      —      sum[a]<=sum[a+b+1]−c−1  ...

  2. vue中的provide/inject的学习使用

    irst:定义一个parent component ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 <template>  <div> ...

  3. AtCoder Grand Contest 026 (AGC026) E - Synchronized Subsequence 贪心 动态规划

    原文链接https://www.cnblogs.com/zhouzhendong/p/AGC026E.html 题目传送门 - AGC026E 题意 给定一个长度为 $2n$ 的字符串,包含 $n$ ...

  4. BZOJ1497 [NOI2006]最大获利 网络流 最小割 SAP

    原文链接http://www.cnblogs.com/zhouzhendong/p/8371052.html 题目传送门 - BZOJ1497 题意概括 有n个站要被建立. 建立第i个站的花费为pi. ...

  5. BZOJ4802 欧拉函数 数论

    原文链接http://www.cnblogs.com/zhouzhendong/p/8117744.html 题目传送门 - BZOJ4802 题意概括 Description 已知N,求phi(N) ...

  6. ELK安装(windows)

    一.安装JAVA环境 在Oracle官网获取最新版的Java版本,官网:http://www.oracle.com/ 安装完成后,配置JAVA_HOME和JRE_HOME. 二.下载安装ELK htt ...

  7. Cloudera Manager的安装

    1.  cloudera manager的概念 简单来说,Cloudera Manager是一个拥有集群自动化安装.中心化管理.集群监控.报警功能的一个工具(软件),使得安装集群从几天的时间缩短在几个 ...

  8. Hadoop |集群的搭建

    Hadoop组成 HDFS(Hadoop Distributed File System)架构概述 NameNode目录--主刀医生(nn):  DataNode(dn)数据: Secondary N ...

  9. python查看对象用法

    python查看类用法: dir(object_name)

  10. Django 学习第九天——请求与响应

    一.HttpRequest 对象: 服务器接收到http协议的请求后,会根据报文创建 HttpRequest 对象视图函数的第一个参数是HttpRequest 对象再django.http 模块中定义 ...