Submission #871626

#TimeUsernameProblemLanguageResultExecution timeMemory
871626vjudge1Difference (POI11_roz)C++17
40 / 100
1097 ms65536 KiB
#include "bits/stdc++.h" using namespace std; const int N = 1e6+5; int n; char c[N]; int sum[N][30]; int Get(int l, int r, int c) { return sum[r][c] - sum[l-1][c]; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin >> n; for (int i = 1 ; i <= n ; i++) { cin >> c[i]; for (int j = 0 ; j < 26 ; j++) sum[i][j] = sum[i-1][j] + (c[i]-'a' == j); } int res = 0; for (int i = 1 ; i <= n ; i++) for (int j = 1 ; j < i ; j++) { int ma = 0, mi = 1e9; for (int c = 0 ; c < 26 ; c++) if (Get(j, i, c)) { ma = max(ma, Get(j, i, c)); mi = min(mi, Get(j, i, c)); } res = max(res, ma-mi); } cout << res; 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...