Submission #753904

#TimeUsernameProblemLanguageResultExecution timeMemory
753904nguyentunglamSequence (APIO23_sequence)C++17
11 / 100
2061 ms5460 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 5e5 + 10; int cnt[N]; int sequence(int n, vector<int> a) { int res = 1; for(int i = 0; i < n; i++) for(int j = i; j < n; j++) { vector<int> v; for(int k = i; k <= j; k++) cnt[a[k]]++, v.push_back(a[k]); sort(v.begin(), v.end()); int m = v.size(); res = max(res, cnt[v[m >> 1]]); res = max(res, cnt[v[m - 1 >> 1]]); for(int k = i; k <= j; k++) cnt[a[k]] = 0; } return res; } #ifdef ngu int main() { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); // int n; cin >> n; // vector<int> a(n); // for(int i = 0; i < n; i++) cin >> a[i]; // cout << sequence(n, a); // cout << sequence(7, {1, 2, 3, 1, 2, 1, 3}); // cout << sequence(9, {1, 1, 2, 3, 4, 3, 2, 1, 1}); // cout << sequence(14, {2, 6, 2, 5, 3, 4, 2, 1, 4, 3, 5, 6, 3, 2}); } #endif // ngu

Compilation message (stderr)

sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:18:32: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   18 |         res = max(res, cnt[v[m - 1 >> 1]]);
      |                              ~~^~~
#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...