-
-
Save theortsac/4f6ac2df6088fdca47a7a5610a4e1605 to your computer and use it in GitHub Desktop.
Solução Forte Demais
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define ll long long | |
int main() { | |
int e, d; | |
cin >> e >> d; | |
vector<int> sideE(e), sideD(d); | |
ll sumE = 0, sumD = 0, delE = 0, delD = 0, ans = 0; | |
for (int i = 0; i < e; i++) { | |
cin >> sideE[i]; | |
sumE += sideE[i]; | |
} | |
for (int i = 0; i < d; i++) { | |
cin >> sideD[i]; | |
sumD += sideD[i]; | |
} | |
int l = 0, r = d-1; | |
while ((sumE - delE)!=(sumD - delD)) { | |
if ((sumE - delE) > (sumD - delD)) { | |
delE += sideE[l]; | |
l++; | |
} else { | |
delD += sideD[r]; | |
r--; | |
} | |
ans++; | |
} | |
cout << ans << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment