제출 #974307

#제출 시각아이디문제언어결과실행 시간메모리
974307Pannda서열 (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; }

컴파일 시 표준 에러 (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...