码迷,mamicode.com
首页 > 其他好文 > 详细

csu 1584: Train Passengers

时间:2015-04-27 09:54:34      阅读:125      评论:0      收藏:0      [点我收藏+]

标签: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; 
} 


csu 1584: Train Passengers

标签:c

原文地址:http://blog.csdn.net/xky1306102chenhong/article/details/45293397

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!