fork download
  1. // C++ includes used for precompiling -*- C++ -*-
  2.  
  3. // Copyright (C) 2003-2013 Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library. This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 3, or (at your option)
  9. // any later version.
  10.  
  11. // This library is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15.  
  16. // Under Section 7 of GPL version 3, you are granted additional
  17. // permissions described in the GCC Runtime Library Exception, version
  18. // 3.1, as published by the Free Software Foundation.
  19.  
  20. // You should have received a copy of the GNU General Public License and
  21. // a copy of the GCC Runtime Library Exception along with this program;
  22. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  23. // <http://w...content-available-to-author-only...u.org/licenses/>.
  24.  
  25. /** @file stdc++.h
  26.  * This is an implementation file for a precompiled header.
  27.  */
  28.  
  29. // 17.4.1.2 Headers
  30.  
  31. // C
  32. #ifndef _GLIBCXX_NO_ASSERT
  33. #include <cassert>
  34. #endif
  35. #include <cctype>
  36. #include <cerrno>
  37. #include <cfloat>
  38. #include <ciso646>
  39. #include <climits>
  40. #include <clocale>
  41. #include <cmath>
  42. #include <csetjmp>
  43. #include <csignal>
  44. #include <cstdarg>
  45. #include <cstddef>
  46. #include <cstdio>
  47. #include <cstdlib>
  48. #include <cstring>
  49. #include <ctime>
  50.  
  51. #if __cplusplus >= 201103L
  52. #include <ccomplex>
  53. #include <cfenv>
  54. #include <cinttypes>
  55. #include <cstdbool>
  56. #include <cstdint>
  57. #include <ctgmath>
  58. #include <cwchar>
  59. #include <cwctype>
  60. #endif
  61.  
  62. // C++
  63. #include <algorithm>
  64. #include <bitset>
  65. #include <complex>
  66. #include <deque>
  67. #include <exception>
  68. #include <fstream>
  69. #include <functional>
  70. #include <iomanip>
  71. #include <ios>
  72. #include <iosfwd>
  73. #include <iostream>
  74. #include <istream>
  75. #include <iterator>
  76. #include <limits>
  77. #include <list>
  78. #include <locale>
  79. #include <map>
  80. #include <memory>
  81. #include <new>
  82. #include <numeric>
  83. #include <ostream>
  84. #include <queue>
  85. #include <set>
  86. #include <sstream>
  87. #include <stack>
  88. #include <stdexcept>
  89. #include <streambuf>
  90. #include <string>
  91. #include <typeinfo>
  92. #include <utility>
  93. #include <valarray>
  94. #include <vector>
  95.  
  96. #if __cplusplus >= 201103L
  97. #include <array>
  98. #include <atomic>
  99. #include <chrono>
  100. #include <condition_variable>
  101. #include <forward_list>
  102. #include <future>
  103. #include <initializer_list>
  104. #include <mutex>
  105. #include <random>
  106. #include <ratio>
  107. #include <regex>
  108. #include <scoped_allocator>
  109. #include <system_error>
  110. #include <thread>
  111. #include <tuple>
  112. #include <typeindex>
  113. #include <type_traits>
  114. #include <unordered_map>
  115. #include <unordered_set>
  116. #endif
  117.  
  118. using namespace std;
  119.  
  120. priority_queue<int> c;
  121. int n, d,moedas = 0, soma = 0, i =0;
  122.  
  123. int main(){
  124. scanf("%d", &n);
  125. while(n--){
  126. scanf("%d", &d);
  127. moedas = moedas+d;
  128. c.push(d);
  129. }
  130. moedas = moedas/2;
  131. printf("%d",moedas);
  132. while(moedas >= soma){
  133. if(c.empty()) break;
  134. soma += c.top();
  135. c.pop();
  136. i++;
  137. }
  138. printf("%d", i);
  139. return 0;
  140. }
Success #stdin #stdout 0s 15240KB
stdin
3
2 1 2
stdout
22