XJOIWINTERCAMPPRECONTEST1-P2 queue

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.