제출 #500947

#제출 시각아이디문제언어결과실행 시간메모리
500947Mounir새로운 문제 (POI11_roz)C++14
0 / 100
950 ms16788 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define sz(x) (int)x.size() #define pb push_back #define pii pair<int, int> #define chmin(x, v) x = min(x, v) #define chmax(x, v) x = max(x, v) #define x first #define y second #define int long long using namespace std; signed main(){ int nVals; cin >> nVals; string line; cin >> line; vector<int> posis[26]; for (int i = 0; i < nVals; ++i) posis[line[i] - 'a'].pb(i); int maxi = 0; for (int iMin = 0; iMin < 26; ++iMin) for (int iMax = 0; iMax < 6; ++iMax){ if (posis[iMin].empty() || posis[iMax].empty()) continue; vector<pii> vals; for (int posi : posis[iMin]) vals.pb({posi, -1}); for (int posi : posis[iMax]) vals.pb({posi, 1}); sort(all(vals)); int pMin = 0, pMax = 0, pCur = 0; for (pii val : vals){ pCur += val.second; chmax(maxi, abs(pCur - pMin)); chmax(maxi, abs(pMax - pCur)); chmin(pMin, pCur); chmax(pMax, pCur); } } cout << maxi << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...