#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long
int main() {
ll n;
cin >> n;
vector <pair <ll,ll> > a(n);
for (int i = 0; i < n; i++)
cin >> a[i].first >> a[i].second;
sort(a.begin(),a.end());
ll maksi = 0, mini = 1000000000000001;
ll maksuma = 0, dsuma = 0;
for (int i = 0; i <= n - 1; i++){
dsuma += a[i].second;
mini = min(a[i].first, mini), maksi = max(a[i].first, maksi);
if (dsuma - maksi + mini > maksuma)
maksuma = dsuma - maksi + mini;
}
cout << maksuma;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |