【POI2017||bzoj4726】Flappy Birds
外国人很良心的啊,这题比NOIP那题还简单……
不用管他最后的位置,因为移动的次数肯定是恒定的,所以维护在每一个柱子的位置能飞到的范围,递推下去即可。
#include<bits/stdc++.h> using namespace std; int n,x,y,ans,pos; inline int read(){ int f=1,x=0;char ch; do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9'); do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9'); return f*x; } int main(){ n=read();int ttt=read(); for(int i=1;i<=n;i++){ int d=read(),l=read(),r=read(); pos+=d-x;y-=d-x;x=d; if(y<=l){int t=(l+2-y)>>1;pos-=t;y+=t<<1;ans+=t;} if(pos<0||y>=r){puts("NIE");return 0;} pos=min(pos,(r-1-y)>>1); } printf("%d\n",ans); }
zzq wc-ctsc-apio-NOI Au;yql精通多项式;zyz精通女装;由乃精通数据结构;孔老师是毒奶大师;我没有学上:我们都有光明的前途。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步