Submission #145557

#TimeUsernameProblemLanguageResultExecution timeMemory
145557surface03택배 (KOI13_delivery)C++14
100 / 100
8 ms632 KiB
#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)

delivery.cpp: In function 'int main()':
delivery.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&V,&t);
     ~~~~~^~~~~~~~~~~~~~~~~~~
delivery.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&b[i].fr,&b[i].re,&b[i].w);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...