标签:c
<span class="sampledata" style="background-color: rgb(141, 184, 255); font-family: monospace; font-size: 18px; white-space: pre;">题意:</span>
<span class="sampledata" style="background-color: rgb(141, 184, 255); font-family: monospace; font-size: 18px; white-space: pre;">1.最后一站,计算完之后,必须车上无人,没人上车,没人等待</span>
<span class="sampledata" style="background-color: rgb(141, 184, 255); font-family: monospace; font-size: 18px; white-space: pre;">2.超出车的容量,必然不行</span>
<span class="sampledata" style="background-color: rgb(141, 184, 255); font-family: monospace; font-size: 18px; white-space: pre;">3.如果车没上满,却还有等待的人,那么是不行的,因为车没上满我干嘛不上啊,还等毛线啊</span>
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { long long C,n; long long x,y,z; int flag; while(scanf("%lld%lld",&C,&n)==2) { long long num=0; flag=1; for(int i=1;i<=n;i++) { scanf("%lld%lld%lld",&x,&y,&z); if(flag==0) continue; if(i<n&&x<=num&&y<C-num+x&&z==0) { num=num-x+y; continue; } if(i<n&&x<=num&&y==C-num+x) { num=num-x+y; continue; } if(i==n&&x==num&&y==0&&z==0) { continue; } flag=0; } if(flag) printf("possible\n"); else printf("impossible\n"); } return 0; }
标签:c
原文地址:http://blog.csdn.net/xky1306102chenhong/article/details/45293397