# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
804403 |
2023-08-03T08:32:58 Z |
model_solution(#10141) |
Fun Palace (CCO18_fun) |
C++17 |
|
72 ms |
79404 KB |
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
const int mxn=1010,mxe=20010;
int dp[mxn][mxe];
void app(int&x,int y)
{
x=max(x,y);
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,e;
cin>>n;
cin>>e;
for(int i=0;i<mxn;i++)
for(int j=0;j<mxe;j++)
dp[i][j]=-inf;
for(int i=0;i<e;i++)
app(dp[1][i],i);
for(int i=1;i<n;i++)
{
int a,b;
cin>>a>>b;
int mx_nopen=*max_element(dp[i],dp[i]+a);
if(mx_nopen>=0)
for(int j=0;j<b;j++)
app(dp[i+1][j],mx_nopen+j);
for(int j=0;j<mxe;j++)
{
if(dp[i][j]<0)
continue;
if(j<a)
app(dp[i+1][j+b],dp[i][j]+b);
else if(j<a+b)
app(dp[i+1][j-a],dp[i][j]);
else
app(dp[i+1][j],dp[i][j]);
}
}
int ans=e-1;
for(int i=0;i<mxe;i++)
ans=max(ans,dp[n][i]);
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
79308 KB |
Output is correct |
2 |
Correct |
32 ms |
79356 KB |
Output is correct |
3 |
Correct |
33 ms |
79404 KB |
Output is correct |
4 |
Correct |
32 ms |
79316 KB |
Output is correct |
5 |
Correct |
32 ms |
79312 KB |
Output is correct |
6 |
Correct |
33 ms |
79304 KB |
Output is correct |
7 |
Correct |
33 ms |
79364 KB |
Output is correct |
8 |
Correct |
33 ms |
79308 KB |
Output is correct |
9 |
Correct |
36 ms |
79316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
79368 KB |
Output is correct |
2 |
Correct |
33 ms |
79300 KB |
Output is correct |
3 |
Correct |
33 ms |
79356 KB |
Output is correct |
4 |
Correct |
33 ms |
79308 KB |
Output is correct |
5 |
Correct |
33 ms |
79300 KB |
Output is correct |
6 |
Correct |
34 ms |
79392 KB |
Output is correct |
7 |
Correct |
52 ms |
79392 KB |
Output is correct |
8 |
Correct |
48 ms |
79400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
79308 KB |
Output is correct |
2 |
Correct |
32 ms |
79356 KB |
Output is correct |
3 |
Correct |
33 ms |
79404 KB |
Output is correct |
4 |
Correct |
32 ms |
79316 KB |
Output is correct |
5 |
Correct |
32 ms |
79312 KB |
Output is correct |
6 |
Correct |
33 ms |
79304 KB |
Output is correct |
7 |
Correct |
33 ms |
79364 KB |
Output is correct |
8 |
Correct |
33 ms |
79308 KB |
Output is correct |
9 |
Correct |
36 ms |
79316 KB |
Output is correct |
10 |
Correct |
33 ms |
79280 KB |
Output is correct |
11 |
Correct |
33 ms |
79304 KB |
Output is correct |
12 |
Correct |
41 ms |
79400 KB |
Output is correct |
13 |
Correct |
34 ms |
79372 KB |
Output is correct |
14 |
Correct |
35 ms |
79316 KB |
Output is correct |
15 |
Correct |
39 ms |
79396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
79308 KB |
Output is correct |
2 |
Correct |
32 ms |
79356 KB |
Output is correct |
3 |
Correct |
33 ms |
79404 KB |
Output is correct |
4 |
Correct |
32 ms |
79316 KB |
Output is correct |
5 |
Correct |
32 ms |
79312 KB |
Output is correct |
6 |
Correct |
33 ms |
79304 KB |
Output is correct |
7 |
Correct |
33 ms |
79364 KB |
Output is correct |
8 |
Correct |
33 ms |
79308 KB |
Output is correct |
9 |
Correct |
36 ms |
79316 KB |
Output is correct |
10 |
Correct |
33 ms |
79368 KB |
Output is correct |
11 |
Correct |
33 ms |
79300 KB |
Output is correct |
12 |
Correct |
33 ms |
79356 KB |
Output is correct |
13 |
Correct |
33 ms |
79308 KB |
Output is correct |
14 |
Correct |
33 ms |
79300 KB |
Output is correct |
15 |
Correct |
34 ms |
79392 KB |
Output is correct |
16 |
Correct |
52 ms |
79392 KB |
Output is correct |
17 |
Correct |
48 ms |
79400 KB |
Output is correct |
18 |
Correct |
33 ms |
79280 KB |
Output is correct |
19 |
Correct |
33 ms |
79304 KB |
Output is correct |
20 |
Correct |
41 ms |
79400 KB |
Output is correct |
21 |
Correct |
34 ms |
79372 KB |
Output is correct |
22 |
Correct |
35 ms |
79316 KB |
Output is correct |
23 |
Correct |
39 ms |
79396 KB |
Output is correct |
24 |
Correct |
44 ms |
79300 KB |
Output is correct |
25 |
Correct |
47 ms |
79352 KB |
Output is correct |
26 |
Correct |
33 ms |
79340 KB |
Output is correct |
27 |
Correct |
72 ms |
79400 KB |
Output is correct |
28 |
Correct |
67 ms |
79348 KB |
Output is correct |
29 |
Correct |
66 ms |
79304 KB |
Output is correct |
30 |
Correct |
54 ms |
79400 KB |
Output is correct |