AOJ 0112 - A Milk Shop
#include <iostream> #include <algorithm> #include <vector> int main(){ int n; while(std::cin>>n,n){ std::vector<int> v; for(;n;n--){ int i; std::cin>>i; v.push_back(i); } std::sort(v.begin(),v.end()); std::vector<int>::iterator it = v.begin(); long long int wtime = 0,stime = 0; while(it!=v.end()){ stime += wtime; wtime += (*it); it++; } std::cout<<stime<<std::endl; } }
Wrong Answerの方は10000人が60分のときを考えるといいそうです.
(それに泣かされた).