Submission #140854

#TimeUsernameProblemLanguageResultExecution timeMemory
140854shafinalamDifference (POI11_roz)C++14
0 / 100
2 ms424 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:8:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define  input freopen("in.txt","r",stdin)
                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
roz.cpp:16:2: note: in expansion of macro 'input'
  input;
  ^~~~~
roz.cpp:9:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define  output freopen("out.txt","w",stdout)
                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
roz.cpp:17:2: note: in expansion of macro 'output'
  output;
  ^~~~~~
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...