Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
10954
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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"; } }
g++
3 1 2 3
Show compiler warnings
[
+
] Compiler args
[
-
]
Show input
Compilation time: 0.87 sec, absolute running time: 0.33 sec, cpu time: 0.26 sec, memory peak: 3 Mb, absolute service time: 1,21 sec
edit mode
|
history
|
discussion
3 6 res:9