QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372148 | #2432. Go with the Flow | We_Are_Chenough# | WA | 1ms | 3848kb | C++17 | 1.4kb | 2024-03-30 23:43:32 | 2024-03-30 23:43:34 |
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 = 0;
if(pos[cont].first==line-1){
atual = pos[cont].second;
}
pos[cont] = {line, atual+1};
pos[cont-1] = {line, atual+1};
pos[cont+1] = {line, atual+1};
resp=max(resp, atual+1);
}
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;
}
Details
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3524kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3484kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3592kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 3600kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 3756kb
Test #7:
score: 0
Accepted
time: 1ms
memory: 3576kb
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3848kb