# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145557 | surface03 | 택배 (KOI13_delivery) | C++14 | 8 ms | 632 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
struct data{
int fr,re,w;
bool operator<(const data&r)const{
if(fr==r.fr)return re<r.re;
return fr<r.fr;
}
}b[10010];
int n,V,t,a[10010],ans,sum,tmp;
int main(){
scanf("%d%d%d",&n,&V,&t);
for(int i=0;i<t;i++){
scanf("%d%d%d",&b[i].fr,&b[i].re,&b[i].w);
}
sort(b,b+t);
for(int i=1,j=0;i<=n;i++){
sum=0;
ans+=a[i];
while(j<t&&b[j].fr==i){
a[b[j].re]+=b[j].w;
j++;
}
for(int k=i+1;k<=n;k++){
sum+=a[k];
if(sum>V){
a[k]-=sum-V;
for(int ic=k+1;ic<=n;ic++)a[ic]=0;
break;
}
}
}
printf("%d",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |