Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: peilin

Problemset: Slowly Express

Language: c

Time: 0.002 second

Submitted On: 2025-10-12 22:48:06

#include <stdio.h>

int main() {
    int w[1000], n = 0, weight;
    while(1) {
        scanf("%d", &weight);
        if(weight < 0) break;
        w[n++] = weight;
    }

    int carry_over = 0, result[1000];
    for(int i = 0; i < n; i++) {
        int total = w[i] + carry_over;
        int trucks = 0;

        if(total >= 500) {
            trucks = total / 800;
            if(total % 800 != 0) trucks++;
            if(total % 800 < 500 && total % 800 != 0) trucks--;
            carry_over = total - trucks * 800;
            if(carry_over < 0) carry_over = 0;
        } else {
            carry_over = total;
            trucks = 0;
        }

        result[i] = trucks;
    }

    for(int i = 0; i < n; i++) {
        printf("%d\n", result[i]);
    }

    return 0;
}