比赛 |
20241022 |
评测结果 |
WWWWWWWWWWWWTTTTTTTT |
题目名称 |
电梯 |
最终得分 |
0 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
16.181 s |
代码语言 |
C++ |
内存使用 |
4.73 MiB |
提交时间 |
2024-10-22 09:36:12 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define in inline
#define se second
#define mp make_pair
#define pb push_back
const int N = 1e5+10;
ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
int n;
ll t[N],a[N],f[N];
int main(){
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
n = read();
for(int i = 1;i <= n;i++)t[i] = read(),a[i] = read();
memset(f,0x3f,sizeof f);
f[0] = 0;
for(int i = 1;i <= n;i++){
ll mx = a[i];
for(int j = i-1;j >= 0;j--){
int k = max(t[i],f[j]);
f[i] = min(f[i],k + 2 * mx);
mx = max(mx,a[j]);
}
// printf("%lld ",f[i]);
}
// printf("\n---\n");
printf("%lld\n",f[n]);
return 0;
}