Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <set>
- #include <map>
- #include <algorithm>
- #include <string>
- #include <math.h>
- #include <vector>
- #include <cmath>
- #include <sstream>
- using namespace std;
- int main()
- {
- long long n, suma=0, sumb=0, a, b, prom;
- long long arry[100001];
- cin >> n;
- for (int i = 1; i <= n; i++)
- {
- cin >> prom;
- arry[i] = prom;
- }
- cin >> a >> b;
- if (a < b)
- {
- for (int i = 1; i <= n; i++)
- {
- if (i <= (a+b)/2)
- suma += arry[i];
- else
- sumb += arry[i];
- }
- }
- else
- if(a>b)
- for (int i = 1; i <= n; i++)
- {
- if (i <= ceil((a+b) / 2.0) - 1)
- sumb += arry[i];
- else
- suma += arry[i];
- }
- else
- {
- for (int i = 1; i <= n; i++)
- {
- if (i < a)
- sumb += arry[i];
- else
- if (i > a)
- suma += arry[i];
- }
- if (suma >= sumb)
- suma = suma + arry[a];
- else
- {
- prom = suma;
- suma = sumb + arry[a];
- sumb = prom;
- }
- }
- cout << suma << endl << sumb;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment