답안 #16852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16852 2015-10-22T07:35:31 Z hjk0553 택배 (KOI13_delivery) C++
100 / 100
27 ms 1208 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
int i,j,k;
int villagecount;
int volume;
int maxcarryweight=0;
int track[2001];
struct delivery
{
    int sendvillage;
    int receivevillage;
    int weight;
} data[10001];
bool compare(const delivery &a,const delivery &b)
{
    return a.receivevillage<b.receivevillage;
}
int main()
{
    //freopen("input.txt","r",stdin);
    scanf("%d %d",&villagecount,&volume);
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d %d",&data[i].sendvillage,&data[i].receivevillage,&data[i].weight);
    }
    sort(data+1,data+1+n,compare);
    for(i=1;i<=n;i++)
    {
        int Max=-1e9;
        int sw=0;
        for(j=data[i].sendvillage;j<data[i].receivevillage;j++) Max=max(Max,track[j]);
        for(j=data[i].sendvillage;j<data[i].receivevillage;j++)
        {
            if(Max+data[i].weight>volume)
            {
                if(Max==0){track[j]=volume;sw=1;}
                else {track[j]+=volume-Max;sw=2;}
            }
            else track[j]+=data[i].weight;
        }
        if(sw==1) maxcarryweight+=volume;
        else if(sw==2) maxcarryweight+=volume-Max;
        else maxcarryweight+=data[i].weight;
    }
    //for(i=1;i<=villagecount;i++)
    //{
    //    printf("%d ",track[i]);
    //}
    printf("%d",maxcarryweight);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1208 KB Output is correct
2 Correct 0 ms 1208 KB Output is correct
3 Correct 0 ms 1208 KB Output is correct
4 Correct 0 ms 1208 KB Output is correct
5 Correct 0 ms 1208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1208 KB Output is correct
2 Correct 0 ms 1208 KB Output is correct
3 Correct 0 ms 1208 KB Output is correct
4 Correct 0 ms 1208 KB Output is correct
5 Correct 0 ms 1208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1208 KB Output is correct
2 Correct 0 ms 1208 KB Output is correct
3 Correct 0 ms 1208 KB Output is correct
4 Correct 0 ms 1208 KB Output is correct
5 Correct 0 ms 1208 KB Output is correct
6 Correct 0 ms 1208 KB Output is correct
7 Correct 0 ms 1208 KB Output is correct
8 Correct 0 ms 1208 KB Output is correct
9 Correct 0 ms 1208 KB Output is correct
10 Correct 0 ms 1208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1208 KB Output is correct
2 Correct 0 ms 1208 KB Output is correct
3 Correct 0 ms 1208 KB Output is correct
4 Correct 0 ms 1208 KB Output is correct
5 Correct 0 ms 1208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1208 KB Output is correct
2 Correct 2 ms 1208 KB Output is correct
3 Correct 26 ms 1208 KB Output is correct
4 Correct 24 ms 1208 KB Output is correct
5 Correct 27 ms 1208 KB Output is correct