2 queuing
2.1 Topics
there are n people to fetch water, and I need the AI time for personal water. There are k taps, you can arrange them to fetch water.
and which faucet to use, but each tap can only be used by one person at a time and once a person opens
You cannot stop the water from starting.
ask for a minimum total wait time for each k 2 [1; n] output.
2.2 Input Format
The first line enters an integer n.
The second line enters n integers to represent the AI.
2.3 Output Format
An integer that outputs a row of n spaces separates the answer.
2.4 Input Sample
51 2 3) 4 5
2.5 Output Example
35 22 18) 16 15
2.6 Data Range
For 20% of data, N 103.
For 50% of data, N 104.
For 100% of data, n 105,1 AI 108.
The most water problem in this competition.
1#include <cstdio>2#include <iostream>3#include <algorithm>4 using namespacestd;5 Long Longd[100001];6 intMain ()7 {8 intN;9scanf"%d",&n);Ten for(intI=1; i<=n;i++) scanf ("%lld",&d[i]); OneSort (d+1, d+n+1); A for(intI=2; i<=n;i++) d[i]+=d[i-1]; - Long Longans=0; - for(intI=1; i<=n;i++) the { -ans=0; - for(intJ=n;j>0; j-=i) ans+=D[j]; -printf"%lld", ans); + } - return 0; +}
XJOIWINTERCAMPPRECONTEST1-P2 queue