# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
258540 |
2020-08-06T05:54:49 Z |
최은수(#5046) |
Vim (BOI13_vim) |
C++17 |
|
335 ms |
201592 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+7;
int st[70010];
bool chk[70010];
ll dp[5010][2510];
int rg[5010][9];
int ps[5010];
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin>>n;
ll ans=0;
vector<int>pv;
int pos=0;
for(int i=0;i++<n;)
{
char c;
cin>>c;
if(c=='e')
{
ans+=2;
chk[i]=1;
i--;
n--;
continue;
}
if(chk[i])
pv.eb(i),pos++;
ps[i]=pos;
st[i]=c-'a';
if(st[i]>4)
st[i]--;
}
for(int i=0;i<9;i++)
rg[n][i]=0;
for(int i=n-1;i>0;i--)
for(int j=0;j<9;j++)
rg[i][j]=st[i+1]==j?i+1:rg[i+1][j];
int m=pv.size();
for(int i=0;i++<n;)
for(int j=0;j<=m;j++)
dp[i][j]=INF;
dp[1][0]=ans;
for(int i=0;i<m;i++)
{
for(int j=0;j++<n;)
{
if(j>=pv[i])
dp[pv[i]][ps[j]]=min(dp[pv[i]][ps[j]],dp[j][i]+j-pv[i]);
for(int k=0;k<9;k++)
if(rg[j][k]!=0)
dp[rg[j][k]][i]=min(dp[rg[j][k]][i],dp[j][i]+2);
}
}
ll mn=INF;
for(int i=0;i++<n;)
mn=min(mn,dp[i][m]);
cout<<mn<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1536 KB |
Output is correct |
2 |
Correct |
2 ms |
1920 KB |
Output is correct |
3 |
Correct |
2 ms |
1536 KB |
Output is correct |
4 |
Correct |
3 ms |
1664 KB |
Output is correct |
5 |
Correct |
4 ms |
1664 KB |
Output is correct |
6 |
Correct |
4 ms |
1920 KB |
Output is correct |
7 |
Correct |
4 ms |
2048 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
1536 KB |
Output is correct |
14 |
Correct |
2 ms |
1920 KB |
Output is correct |
15 |
Correct |
2 ms |
1536 KB |
Output is correct |
16 |
Correct |
3 ms |
1792 KB |
Output is correct |
17 |
Correct |
3 ms |
2176 KB |
Output is correct |
18 |
Correct |
3 ms |
1664 KB |
Output is correct |
19 |
Correct |
2 ms |
1408 KB |
Output is correct |
20 |
Correct |
3 ms |
1536 KB |
Output is correct |
21 |
Correct |
3 ms |
1664 KB |
Output is correct |
22 |
Correct |
4 ms |
1664 KB |
Output is correct |
23 |
Correct |
3 ms |
2176 KB |
Output is correct |
24 |
Correct |
3 ms |
2048 KB |
Output is correct |
25 |
Correct |
3 ms |
1920 KB |
Output is correct |
26 |
Correct |
3 ms |
2048 KB |
Output is correct |
27 |
Correct |
4 ms |
1920 KB |
Output is correct |
28 |
Correct |
3 ms |
1920 KB |
Output is correct |
29 |
Correct |
3 ms |
2048 KB |
Output is correct |
30 |
Correct |
3 ms |
2176 KB |
Output is correct |
31 |
Correct |
3 ms |
1920 KB |
Output is correct |
32 |
Correct |
3 ms |
2176 KB |
Output is correct |
33 |
Correct |
3 ms |
2176 KB |
Output is correct |
34 |
Correct |
3 ms |
1792 KB |
Output is correct |
35 |
Correct |
3 ms |
1664 KB |
Output is correct |
36 |
Correct |
4 ms |
2048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
156 ms |
29568 KB |
Output is correct |
2 |
Correct |
335 ms |
52600 KB |
Output is correct |
3 |
Correct |
66 ms |
14976 KB |
Output is correct |
4 |
Correct |
158 ms |
29568 KB |
Output is correct |
5 |
Correct |
325 ms |
54676 KB |
Output is correct |
6 |
Correct |
283 ms |
53880 KB |
Output is correct |
7 |
Correct |
204 ms |
38412 KB |
Output is correct |
8 |
Correct |
210 ms |
37888 KB |
Output is correct |
9 |
Correct |
331 ms |
52600 KB |
Output is correct |
10 |
Correct |
303 ms |
55544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
197 ms |
201396 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
186 ms |
201464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
184 ms |
201384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
200 ms |
201464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
193 ms |
201576 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
190 ms |
201592 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
202 ms |
201464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
218 ms |
201592 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
216 ms |
201576 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
199 ms |
201496 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
206 ms |
201468 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
199 ms |
201588 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
190 ms |
201592 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
192 ms |
201464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
239 ms |
201536 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
191 ms |
201408 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
210 ms |
201336 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
208 ms |
201380 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
210 ms |
201364 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
243 ms |
201572 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |