Submission #4953

#TimeUsernameProblemLanguageResultExecution timeMemory
4953hana5505택배 (KOI13_delivery)C++98
100 / 100
20 ms2336 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...