# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1103939 | 2024-10-22T09:55:10 Z | thangdz2k7 | Difference (POI11_roz) | C++17 | 319 ms | 54860 KB |
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define endl '\n' using namespace std; using ll = long long; using ii = pair <int, int>; using vi = vector <int>; const int N = 1e6 + 1; const int mod = 1e9 + 7; const int nc = 26; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} int n, cur[nc], Min[nc]; string s; vector <int> last[nc]; void solve(){ cin >> n; cin >> s; s = ' ' + s; int ans = 0; for (int u = 0; u < nc; ++ u){ for (int v = 0; v < nc; ++ v) { cur[v] = 0; Min[v] = 1e9; last[v].clear(); last[v].pb(0); } for (int i = 1; i <= n; ++ i){ int v = s[i] - 'a'; if (u == v) { for (int k = 0; k < nc; ++ k) { cur[k] ++; if (k != u){ last[k].push_back(cur[k]); maxl(ans, cur[k] - Min[k]); } } } else { cur[v] --; for (int val : last[v]) minl(Min[v], val); last[v].clear(); last[v].pb(cur[v]); maxl(ans, cur[v] - Min[v]); } } } cout << ans; } int main(){ if (fopen("chenhlech.inp", "r")){ freopen("chenhlech.inp", "r", stdin); freopen("chenhlech.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t --) solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 4 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 299 ms | 3320 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 197 ms | 3928 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 296 ms | 3320 KB | Output is correct |
2 | Correct | 259 ms | 2796 KB | Output is correct |
3 | Correct | 128 ms | 12232 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 319 ms | 3308 KB | Output is correct |
2 | Runtime error | 236 ms | 51056 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 307 ms | 3308 KB | Output is correct |
2 | Runtime error | 207 ms | 54860 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |