Submission #4832

#TimeUsernameProblemLanguageResultExecution timeMemory
4832gs13068택배 (KOI13_delivery)C++98
100 / 100
20 ms1212 KiB
#include<cstdio> #include<algorithm> struct delivery { int start; int end; int howmany; } d[10000]; inline bool operator <(const delivery &a,const delivery &b) { if(a.end!=b.end)return a.end<b.end; if(a.start!=b.start)return a.start>b.start; return a.howmany>b.howmany; } int a[2001]; int main() { int i,j,n,m,c,res=0,min; scanf("%d%d%d",&n,&c,&m); for(i=0;i<m;i++)scanf("%d%d%d",&d[i].start,&d[i].end,&d[i].howmany); std::sort(d,d+m); for(i=0;i<m;i++) { min=d[i].howmany; for(j=d[i].start;j<d[i].end;j++)if(c-a[j]<min)min=c-a[j]; res+=min; for(j=d[i].start;j<d[i].end;j++)a[j]+=min; } printf("%d",res); }
#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...