Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n, a[100500], inf = -1000000000, t[500500];
- int main(){
- freopen("C.in", "r", stdin);
- freopen("C.out", "w", stdout);
- cin >> n;
- for(int i = 1; i <= n; u++){
- cin >> a[i];
- }
- sz = 1;
- while(sz < n){
- sz *= 2;
- }
- for(int i = sz; i <= n + sz - 1; i++){
- t[i] = a[i - sz + 1];
- }
- for(int i = sz + n; i <= sz + sz - 1; i++){
- t[i] = -inf;
- }
- for(int i = sz - 1; i >= 1; i--){
- t[i] = t[i * 2] + t[i * 2 + 1];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement