Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(void) {
- int n, s[10004], a, b;
- freopen("in.txt", "r", stdin);
- for (int te = 1; cin >> n && n; te++) {
- for (int i = 0; i < n; i++) {
- cin >> a >> b;
- s[i] = a - b;
- }
- int aux = 0, aux2 = 0;
- pair<int, int> ans = { 1, 1 };
- for (int i = 0; i < n; i++) {
- int x = aux + s[i];
- if (x > s[i]) {
- ans.second++;
- aux = x;
- }
- else {
- ans.first = i + 1, ans.second = i + 1;
- aux = s[i];
- }
- aux2 = max(aux2, aux);
- }
- cout << aux2 << "\n";
- cout << "Teste " << te << "\n";
- if (aux2 > 0)
- cout << ans.first << " " << ans.second << "\n\n";
- else
- cout << "nenhum\n\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement