#include
int n, map[1001], ans = 0;
int main(){
scanf("%d", &n);
int maxy = 0, miny = 1005;
for (int i = 0; i < n; i++){
int a, b;
scanf("%d%d", &a, &b);
map[a] = b;
if (a > maxy) maxy = a;
if (a < miny) miny = a;
}
int idx = map[miny];
for (int i = miny; i <= maxy; i++){
if (idx < map[i])idx = map[i];
ans = ans + idx;
}
if (idx > map[maxy]){
for (int i = maxy;; i--){
if (idx == map[i])
break;
else{
if (map[i]>map[maxy]){
ans = ans - (idx - map[i]);
map[maxy] = map[i];
}
else
ans = ans - (idx - map[maxy]);
}
}
}
printf("%d", ans);
return 0;
}
댓글 없음:
댓글 쓰기