QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372173 | #2432. Go with the Flow | We_Are_Chenough | AC ✓ | 1160ms | 5520kb | C++14 | 1.8kb | 2024-03-31 01:46:23 | 2024-03-31 01:46:25 |
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;
}
if(pos[cont].first!=line){
pos[cont] = {line, atual};
}else{
pos[cont].second = max(pos[cont].second, atual);
}
if(pos[cont+1].first!=line){
pos[cont+1] = {line, atual};
}else{
pos[cont+1].second = max(pos[cont+1].second, atual);
}
if(pos[cont-1].first!=line){
pos[cont-1] = {line, atual};
}else{
pos[cont-1].second = max(pos[cont-1].second, 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;
}
Details
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3540kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 3584kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 3536kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3596kb
Test #8:
score: 0
Accepted
time: 0ms
memory: 3436kb
Test #9:
score: 0
Accepted
time: 0ms
memory: 3628kb
Test #10:
score: 0
Accepted
time: 0ms
memory: 3616kb
Test #11:
score: 0
Accepted
time: 0ms
memory: 3548kb
Test #12:
score: 0
Accepted
time: 1ms
memory: 3576kb
Test #13:
score: 0
Accepted
time: 28ms
memory: 3684kb
Test #14:
score: 0
Accepted
time: 24ms
memory: 3728kb
Test #15:
score: 0
Accepted
time: 29ms
memory: 3676kb
Test #16:
score: 0
Accepted
time: 286ms
memory: 4296kb
Test #17:
score: 0
Accepted
time: 293ms
memory: 4292kb
Test #18:
score: 0
Accepted
time: 286ms
memory: 4220kb
Test #19:
score: 0
Accepted
time: 98ms
memory: 4028kb
Test #20:
score: 0
Accepted
time: 44ms
memory: 3672kb
Test #21:
score: 0
Accepted
time: 640ms
memory: 4780kb
Test #22:
score: 0
Accepted
time: 1145ms
memory: 5400kb
Test #23:
score: 0
Accepted
time: 34ms
memory: 3936kb
Test #24:
score: 0
Accepted
time: 43ms
memory: 3676kb
Test #25:
score: 0
Accepted
time: 401ms
memory: 4392kb
Test #26:
score: 0
Accepted
time: 409ms
memory: 4448kb
Test #27:
score: 0
Accepted
time: 394ms
memory: 4644kb
Test #28:
score: 0
Accepted
time: 97ms
memory: 3944kb
Test #29:
score: 0
Accepted
time: 106ms
memory: 3960kb
Test #30:
score: 0
Accepted
time: 100ms
memory: 4176kb
Test #31:
score: 0
Accepted
time: 1075ms
memory: 5352kb
Test #32:
score: 0
Accepted
time: 633ms
memory: 4528kb
Test #33:
score: 0
Accepted
time: 710ms
memory: 4736kb
Test #34:
score: 0
Accepted
time: 33ms
memory: 3952kb
Test #35:
score: 0
Accepted
time: 1ms
memory: 3516kb
Test #36:
score: 0
Accepted
time: 629ms
memory: 4548kb
Test #37:
score: 0
Accepted
time: 1103ms
memory: 5212kb
Test #38:
score: 0
Accepted
time: 1089ms
memory: 5232kb
Test #39:
score: 0
Accepted
time: 901ms
memory: 5252kb
Test #40:
score: 0
Accepted
time: 950ms
memory: 5324kb
Test #41:
score: 0
Accepted
time: 966ms
memory: 5096kb
Test #42:
score: 0
Accepted
time: 1108ms
memory: 5260kb
Test #43:
score: 0
Accepted
time: 1135ms
memory: 5520kb
Test #44:
score: 0
Accepted
time: 1096ms
memory: 5244kb
Test #45:
score: 0
Accepted
time: 906ms
memory: 5004kb
Test #46:
score: 0
Accepted
time: 883ms
memory: 4932kb
Test #47:
score: 0
Accepted
time: 893ms
memory: 5192kb
Test #48:
score: 0
Accepted
time: 882ms
memory: 4932kb
Test #49:
score: 0
Accepted
time: 1054ms
memory: 5156kb
Test #50:
score: 0
Accepted
time: 998ms
memory: 5100kb
Test #51:
score: 0
Accepted
time: 912ms
memory: 4976kb
Test #52:
score: 0
Accepted
time: 907ms
memory: 4944kb
Test #53:
score: 0
Accepted
time: 763ms
memory: 4768kb
Test #54:
score: 0
Accepted
time: 1ms
memory: 3628kb
Test #55:
score: 0
Accepted
time: 36ms
memory: 3940kb
Test #56:
score: 0
Accepted
time: 4ms
memory: 3620kb
Test #57:
score: 0
Accepted
time: 1140ms
memory: 5400kb
Test #58:
score: 0
Accepted
time: 1160ms
memory: 5412kb
Test #59:
score: 0
Accepted
time: 40ms
memory: 3896kb
Test #60:
score: 0
Accepted
time: 23ms
memory: 3716kb
Test #61:
score: 0
Accepted
time: 1ms
memory: 3568kb
Test #62:
score: 0
Accepted
time: 17ms
memory: 3832kb
Test #63:
score: 0
Accepted
time: 122ms
memory: 4040kb
Test #64:
score: 0
Accepted
time: 50ms
memory: 3992kb
Test #65:
score: 0
Accepted
time: 813ms
memory: 5088kb
Test #66:
score: 0
Accepted
time: 1ms
memory: 3836kb