QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#372166 | #2432. Go with the Flow | We_Are_Chenough | WA | 1ms | 3764kb | C++14 | 1.4kb | 2024-03-31 00:51:01 | 2024-03-31 00:51:03 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define endl '\n'
typedef long long ll;
const int mxn = 202505;
int n;
pair<int, int> pos[mxn];
vector<string> wrds;
int line = 0;
int testa(int len){
int cont = 0, resp = 0;
for(int i = 0; i<n-1; i++){
cont+=(int)wrds[i].size();
if(cont + 1 + (int)wrds[i+1].size()>len){
cont = 0;
line++;
continue;
}
cont++;
int atual = 1;
if(pos[cont].first==line-1){
atual = pos[cont].second + 1;
}
pos[cont] = {line, atual};
pos[cont-1] = {line, atual};
pos[cont+1] = {line, atual};
resp=max(resp, atual);
}
line+=2;
return resp;
}
signed main(){
ios_base::sync_with_stdio(false), cin.tie(nullptr);
cin >> n;
int maior = 0, soma = 0;
for(int i=0; i<n; i++){
string a;
cin >> a;
maior = max(maior, int(a.size()));
soma += int(a.size());
wrds.push_back(a);
}
pair<int, int> ans = {0, 0};
for(int i=maior; i<soma + n; i++){
int agr = testa(i);
if(agr > ans.first){
ans.first = agr;
ans.second = i;
}
}
cout << ans.second << ' ' << ans.first << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3540kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
Test #3:
score: 0
Accepted
time: 1ms
memory: 3588kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3548kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 3504kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 3764kb
Test #7:
score: 0
Accepted
time: 1ms
memory: 3760kb
Test #8:
score: -100
Wrong Answer
time: 1ms
memory: 3624kb