답안 #145557

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145557 2019-08-20T11:43:19 Z surface03 택배 (KOI13_delivery) C++14
100 / 100
8 ms 632 KB
#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

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);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 368 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 252 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 8 ms 632 KB Output is correct
4 Correct 8 ms 632 KB Output is correct
5 Correct 8 ms 632 KB Output is correct