Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
10954
//g++ 5.4.0 #include <iostream> #include <queue> using namespace std; int main() { priority_queue<int,vector<int>,greater<int>> entradas; int cantidad ,numero, suma,resultado; while(cin>>cantidad and cantidad !=0){ resultado=0; for(int i =0; i<cantidad; i++){ cin>>numero; entradas.push(numero); } /*entradas.pop(); cout<<entradas.top();*/ suma=entradas.top(); entradas.pop(); for(int i =0; i<cantidad-1; i++){ suma=suma+entradas.top(); //cout<<suma<<"\n"; resultado=resultado+suma; entradas.pop(); } cout<<"res:"<<resultado<<"\n"; } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
32535
codechef
LALALALALALLLLAAA
Updated Linked Lists - 5/10/2017 V4.0
Policy based smart pointer
Stock buy/sell, maximum subarray problem
looping with pointer
Good1
Изволов#2
count pairs with given sum hashing
stackse - search stackoverflow differently
Please log in to post a comment.