제출 #974375

#제출 시각아이디문제언어결과실행 시간메모리
974375isirazeev서열 (APIO23_sequence)C++17
0 / 100
2040 ms31668 KiB
#include <bits/stdc++.h> using namespace std; int sequence(int n, vector<int> a) { vector<int> pos[n + 1]; for (int i = 0; i < n; i++) pos[a[i]].emplace_back(i); int res = 0; for (int val = 1; val <= n; val++) { for (int L = 1; L <= n; L++) { int c1 = 0, c2 = 0; for (int R = L; R <= n; R++) { c1 += (a[R] < val), c2 += (a[R] > val); if(abs(c1 - c2) <= (R - L + 1) - (c1 + c2) && (R - L + 1) > c1 + c2){ res = max(res, R - L + 1 - c1 - c2); } } } } return res; } //int main() { // ios_base::sync_with_stdio(false); // cin.tie(nullptr), cout.tie(nullptr); // int N; // cin >> N; // vector<int> A(N); // for (int i = 0; i < N; i++) cin >> A[i]; // cout << sequence(N, A); // return 0; //}
#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...