Submission #4953

# Submission time Handle Problem Language Result Execution time Memory
4953 2014-01-23T14:27:12 Z hana5505 택배 (KOI13_delivery) C++
100 / 100
20 ms 2336 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
struct pp{
    int from;
    int to;
    int dil;
}ar[100001];
int aa[20001];
int int_max(int a,int b){
    if(a>b) return a;
    return b;
}
bool cmp(struct pp a,struct pp b){
    if(a.to==b.to){
        if(a.from==b.from) return a.dil>b.dil;
        return a.from>b.from;
    }
    return a.to<b.to;
}
int main()
{
    int n,m,c,i,j,t,ans=0;
 
    scanf("%d %d",&n,&c);
    scanf("%d",&m);
    for(i=1;i<=m;i++)
        scanf("%d %d %d",&ar[i].from,&ar[i].to,&ar[i].dil);
 
    sort(ar+1,ar+m+1,cmp);
 
    for(i=1;i<=m;i++){
        t=0;
        for(j=ar[i].from;j<ar[i].to;j++) t=int_max(t,aa[j]);
        if(t+ar[i].dil<=c){
            for(j=ar[i].from;j<ar[i].to;j++) aa[j]+=ar[i].dil;
            ans+=ar[i].dil;
        }
        else{
            for(j=ar[i].from;j<ar[i].to;j++) aa[j]+=c-t;
            ans+=c-t;
        }
    }
 
    printf("%d",ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2336 KB Output is correct
2 Correct 0 ms 2336 KB Output is correct
3 Correct 0 ms 2336 KB Output is correct
4 Correct 0 ms 2336 KB Output is correct
5 Correct 0 ms 2336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2336 KB Output is correct
2 Correct 0 ms 2336 KB Output is correct
3 Correct 0 ms 2336 KB Output is correct
4 Correct 0 ms 2336 KB Output is correct
5 Correct 0 ms 2336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2336 KB Output is correct
2 Correct 0 ms 2336 KB Output is correct
3 Correct 0 ms 2336 KB Output is correct
4 Correct 0 ms 2336 KB Output is correct
5 Correct 0 ms 2336 KB Output is correct
6 Correct 0 ms 2336 KB Output is correct
7 Correct 0 ms 2336 KB Output is correct
8 Correct 0 ms 2336 KB Output is correct
9 Correct 0 ms 2336 KB Output is correct
10 Correct 0 ms 2336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2336 KB Output is correct
2 Correct 0 ms 2336 KB Output is correct
3 Correct 0 ms 2336 KB Output is correct
4 Correct 0 ms 2336 KB Output is correct
5 Correct 0 ms 2336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2336 KB Output is correct
2 Correct 0 ms 2336 KB Output is correct
3 Correct 20 ms 2336 KB Output is correct
4 Correct 16 ms 2336 KB Output is correct
5 Correct 20 ms 2336 KB Output is correct