Submission #140855

#TimeUsernameProblemLanguageResultExecution timeMemory
140855shafinalamDifference (POI11_roz)C++14
90 / 100
702 ms16144 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second const int mxn = 1e6+5; typedef pair<int,int>pii; #define input freopen("in.txt","r",stdin) #define output freopen("out.txt","w",stdout) #define all(v) v.begin(), v.end() vector<pii>arr[30]; pii tmp[mxn]; int main() { //input; //output; int n; scanf("%d", &n); char ch; for(int i = 0; i < n; i++) { scanf(" %c", &ch); arr[ch-'a'].push_back(make_pair(i, ch-'a')); } int ans = -1; for(int i = 0; i < 26; i++) { for(int r = 0; r < 26; r++) { //if(i==r) continue; merge(all(arr[i]), all(arr[r]), tmp); int k = arr[i].size()+arr[r].size(); int sum = 0, best = -(1<<30); for(int j = 0; j < k; j++) { if(tmp[j].ss==i) { sum++; best++; } else { best = sum-1; sum = max(sum-1, 0); } ans = max(ans, best); } } } printf("%d\n", ans); return 0; }

Compilation message (stderr)

roz.cpp: In function 'int main()':
roz.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
roz.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c", &ch);
   ~~~~~^~~~~~~~~~~~
#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...