cses

solution to cses exercise problems
git clone git://git.superpozycja.net/cses
Log | Files | Refs | README

commit 86c9082fc9aad1a92be153466ba1e10bf26880a6
parent e3eedd1cf4831ddafe9729e42176f39861596186
Author: superpozycja <anna@superpozycja.net>
Date:   Fri,  1 Nov 2024 23:11:13 +0100

solve reading books

Diffstat:
Asorting_and_searching/reading_books.cpp | 48++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+), 0 deletions(-)

diff --git a/sorting_and_searching/reading_books.cpp b/sorting_and_searching/reading_books.cpp @@ -0,0 +1,48 @@ +#include <bits/stdc++.h> +#include <ext/pb_ds/assoc_container.hpp> +#include <ext/pb_ds/tree_policy.hpp> +using namespace std; +using namespace __gnu_pbds; + +template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; + +using ui = unsigned int; +using l = long; +using ul = unsigned long; +using ll = long long; +using ull = unsigned long long; + +using vi = vector<int>; +using vui = vector<ui>; +using vl = vector<l>; +using vul = vector<ul>; +using vll = vector<ll>; +using vull = vector<ull>; + +void solve() +{ + int n; + cin >> n; + l rst = 0; + l mx = 0; + for (int i = 0; i < n; i++) { + l t; + cin >> t; + rst += t; + mx = max(t, mx); + } + rst -= mx; + + if (mx > rst) { + cout << 2 * mx << "\n"; + } else { + cout << mx + rst << "\n"; + } +} + +int main() +{ + ios::sync_with_stdio(0); + cin.tie(0); + solve(); +}