QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#372890 | #2432. Go with the Flow | TWTP_TCTF# | RE | 1890ms | 4128kb | C++17 | 1.4kb | 2024-03-31 20:22:12 | 2024-03-31 20:22:12 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7, A = 26;
int last[N], mx[N], id = 0, n;
vector<string> s;
int mxval(int i) {
int ans = 0;
if (last[i] == id - 1)
ans = max(ans, mx[i]);
if (i && last[i - 1] == id - 1)
ans = max(ans, mx[i - 1]);
if (last[i + 1] == id - 1)
ans = max(ans, mx[i + 1]);
return ans + 1;
}
int getmax(int len) {
int rem = len, ans = 0, i = 0;
id+=2;
for (auto it: s) {
if (it.size() + (rem != len) > rem) {
id++;
rem = len;
i = 0;
}
if (i) {
mx[i] = mxval(i);
last[i] = id;
ans = max(ans, mx[i]);
}
rem -= it.size() + (rem != len);
i += it.size() + (rem != len);
}
return ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
int mn = 1e9, total = n;
s = vector<string>(n);
for (auto &it: s) {
cin >> it;
total += it.size();
mn = min(mn, (int) it.size());
}
int ans = -1, ansindex = -1;
for (int i = mn; i <= total; i++) {
int res = getmax(i);
if (res > ans) {
ans = res;
ansindex = i;
}
}
cout << ansindex << " " << ans << "\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3624kb
Test #2:
score: 0
Accepted
time: 1ms
memory: 3612kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3652kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3564kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 3572kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 3676kb
Test #7:
score: 0
Accepted
time: 1ms
memory: 3708kb
Test #8:
score: 0
Accepted
time: 0ms
memory: 3616kb
Test #9:
score: 0
Accepted
time: 1ms
memory: 3612kb
Test #10:
score: 0
Accepted
time: 1ms
memory: 3708kb
Test #11:
score: 0
Accepted
time: 0ms
memory: 3656kb
Test #12:
score: 0
Accepted
time: 1ms
memory: 3720kb
Test #13:
score: 0
Accepted
time: 77ms
memory: 3780kb
Test #14:
score: 0
Accepted
time: 74ms
memory: 3780kb
Test #15:
score: 0
Accepted
time: 78ms
memory: 3676kb
Test #16:
score: 0
Accepted
time: 1890ms
memory: 4104kb
Test #17:
score: 0
Accepted
time: 1838ms
memory: 4128kb
Test #18:
score: 0
Accepted
time: 1815ms
memory: 4076kb
Test #19:
score: 0
Accepted
time: 291ms
memory: 3808kb
Test #20:
score: 0
Accepted
time: 154ms
memory: 3692kb
Test #21:
score: -100
Runtime Error