Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <algorithm>
- #define MAXN 1000
- using namespace std;
- int N;
- int H[MAXN + 1] { 0 };
- int P = 5000, Max = 0, MaxSave = -200;
- int main() {
- ifstream in("input.txt");
- ofstream out("output.txt");
- in >> N;
- for(int i = 0, j; i < N; i++) {
- in >> j;
- P += j;
- H[i] = P;
- }
- for(int i = 0; i < N; i++) {
- int temp = H[i];
- int mycount = count(H, H+N, temp);
- if(mycount > Max) {
- Max = mycount;
- MaxSave = temp;
- }
- }
- out << MaxSave << endl;
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment