Submission #974307

#TimeUsernameProblemLanguageResultExecution timeMemory
974307PanndaSequence (APIO23_sequence)C++17
7 / 100
106 ms33516 KiB
#include "sequence.h" #include <bits/stdc++.h> using namespace std; int sequence(int n, vector<int> a) { vector<vector<int>> mp(n); for (int i = 0; i < n; i++) { a[i]--; mp[a[i]].push_back(i); } int ans = 0; for (int i = 0, c; i < n; i++) { if (i == 0 || a[i] != a[i - 1]) { c = 1; } else { c++; } ans = max(ans, c); } for (int med = 0; med < n; med++) { if (mp[med].size() < 2) continue; int l = mp[med].front(); int r = mp[med].back() + 1; if (2 * (n - r + l + mp[med].size()) >= n) { ans = max(ans, (int)mp[med].size()); } } return ans; }

Compilation message (stderr)

sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:27:46: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |         if (2 * (n - r + l + mp[med].size()) >= n) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
#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...