QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#521174 | #2432. Go with the Flow | JooDdae | AC ✓ | 1888ms | 3932kb | C++20 | 1.2kb | 2024-08-15 23:05:11 | 2024-08-15 23:05:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, S, d[3030];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i=1;i<=n;i++) {
string s; cin >> s;
d[i] = s.size(), S += d[i]+1;
}
int mx = *max_element(d+1, d+1+n);
int ans1 = 0, ans2 = 0;
for(int L=mx;L<S;L++) {
vector<array<int, 2>> tmp;
for(int i=1;i<=n;i++) {
int C = d[i], j = i;
vector<array<int, 2>> dp;
while(j+1 <= n && C+1+d[j+1] <= L) dp.push_back({++C, 1}), C += d[++j];
for(int a=0, b=0;a<dp.size();a++) {
while(b < tmp.size() && tmp[b][0] <= dp[a][0]) b++;
if(2 <= b && tmp[b-2][0]+1 >= dp[a][0]) dp[a][1] = max(dp[a][1], tmp[b-2][1]+1);
if(1 <= b && tmp[b-1][0]+1 >= dp[a][0]) dp[a][1] = max(dp[a][1], tmp[b-1][1]+1);
if(b < tmp.size() && tmp[b][0]-1 == dp[a][0]) dp[a][1] = max(dp[a][1], tmp[b][1]+1);
if(dp[a][1] > ans2) ans2 = dp[a][1], ans1 = L;
}
swap(dp, tmp), i = j;
}
}
cout << ans1 << " " << ans2 << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3636kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 3588kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 3880kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3644kb
Test #8:
score: 0
Accepted
time: 0ms
memory: 3652kb
Test #9:
score: 0
Accepted
time: 0ms
memory: 3872kb
Test #10:
score: 0
Accepted
time: 0ms
memory: 3636kb
Test #11:
score: 0
Accepted
time: 0ms
memory: 3684kb
Test #12:
score: 0
Accepted
time: 1ms
memory: 3588kb
Test #13:
score: 0
Accepted
time: 49ms
memory: 3608kb
Test #14:
score: 0
Accepted
time: 52ms
memory: 3608kb
Test #15:
score: 0
Accepted
time: 49ms
memory: 3504kb
Test #16:
score: 0
Accepted
time: 526ms
memory: 3712kb
Test #17:
score: 0
Accepted
time: 516ms
memory: 3652kb
Test #18:
score: 0
Accepted
time: 514ms
memory: 3648kb
Test #19:
score: 0
Accepted
time: 158ms
memory: 3912kb
Test #20:
score: 0
Accepted
time: 84ms
memory: 3712kb
Test #21:
score: 0
Accepted
time: 1193ms
memory: 3708kb
Test #22:
score: 0
Accepted
time: 1846ms
memory: 3708kb
Test #23:
score: 0
Accepted
time: 40ms
memory: 3648kb
Test #24:
score: 0
Accepted
time: 84ms
memory: 3644kb
Test #25:
score: 0
Accepted
time: 729ms
memory: 3924kb
Test #26:
score: 0
Accepted
time: 735ms
memory: 3932kb
Test #27:
score: 0
Accepted
time: 742ms
memory: 3924kb
Test #28:
score: 0
Accepted
time: 182ms
memory: 3556kb
Test #29:
score: 0
Accepted
time: 209ms
memory: 3704kb
Test #30:
score: 0
Accepted
time: 186ms
memory: 3660kb
Test #31:
score: 0
Accepted
time: 1687ms
memory: 3880kb
Test #32:
score: 0
Accepted
time: 978ms
memory: 3716kb
Test #33:
score: 0
Accepted
time: 1121ms
memory: 3644kb
Test #34:
score: 0
Accepted
time: 41ms
memory: 3712kb
Test #35:
score: 0
Accepted
time: 0ms
memory: 3872kb
Test #36:
score: 0
Accepted
time: 1179ms
memory: 3716kb
Test #37:
score: 0
Accepted
time: 1769ms
memory: 3648kb
Test #38:
score: 0
Accepted
time: 1854ms
memory: 3604kb
Test #39:
score: 0
Accepted
time: 1484ms
memory: 3704kb
Test #40:
score: 0
Accepted
time: 1544ms
memory: 3712kb
Test #41:
score: 0
Accepted
time: 1580ms
memory: 3872kb
Test #42:
score: 0
Accepted
time: 1755ms
memory: 3644kb
Test #43:
score: 0
Accepted
time: 1785ms
memory: 3712kb
Test #44:
score: 0
Accepted
time: 1801ms
memory: 3876kb
Test #45:
score: 0
Accepted
time: 1472ms
memory: 3684kb
Test #46:
score: 0
Accepted
time: 1472ms
memory: 3720kb
Test #47:
score: 0
Accepted
time: 1474ms
memory: 3912kb
Test #48:
score: 0
Accepted
time: 1457ms
memory: 3748kb
Test #49:
score: 0
Accepted
time: 1682ms
memory: 3712kb
Test #50:
score: 0
Accepted
time: 1569ms
memory: 3652kb
Test #51:
score: 0
Accepted
time: 1495ms
memory: 3680kb
Test #52:
score: 0
Accepted
time: 1472ms
memory: 3672kb
Test #53:
score: 0
Accepted
time: 1336ms
memory: 3708kb
Test #54:
score: 0
Accepted
time: 1ms
memory: 3584kb
Test #55:
score: 0
Accepted
time: 73ms
memory: 3640kb
Test #56:
score: 0
Accepted
time: 9ms
memory: 3624kb
Test #57:
score: 0
Accepted
time: 1846ms
memory: 3648kb
Test #58:
score: 0
Accepted
time: 1888ms
memory: 3684kb
Test #59:
score: 0
Accepted
time: 80ms
memory: 3664kb
Test #60:
score: 0
Accepted
time: 51ms
memory: 3656kb
Test #61:
score: 0
Accepted
time: 1ms
memory: 3584kb
Test #62:
score: 0
Accepted
time: 36ms
memory: 3592kb
Test #63:
score: 0
Accepted
time: 229ms
memory: 3864kb
Test #64:
score: 0
Accepted
time: 99ms
memory: 3596kb
Test #65:
score: 0
Accepted
time: 1416ms
memory: 3652kb
Test #66:
score: 0
Accepted
time: 0ms
memory: 3808kb