답안 #753904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753904 2023-06-06T09:44:32 Z nguyentunglam 서열 (APIO23_sequence) C++17
11 / 100
2000 ms 5460 KB
#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

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]]);
      |                              ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 7 ms 212 KB Output is correct
5 Correct 6 ms 212 KB Output is correct
6 Correct 5 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 7 ms 212 KB Output is correct
10 Correct 6 ms 212 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 7 ms 212 KB Output is correct
5 Correct 6 ms 212 KB Output is correct
6 Correct 5 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 7 ms 212 KB Output is correct
10 Correct 6 ms 212 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 212 KB Output is correct
13 Execution timed out 2061 ms 328 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 2051 ms 5460 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 2036 ms 4460 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2059 ms 5128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 7 ms 212 KB Output is correct
5 Correct 6 ms 212 KB Output is correct
6 Correct 5 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 7 ms 212 KB Output is correct
10 Correct 6 ms 212 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 212 KB Output is correct
13 Execution timed out 2061 ms 328 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 7 ms 212 KB Output is correct
5 Correct 6 ms 212 KB Output is correct
6 Correct 5 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 7 ms 212 KB Output is correct
10 Correct 6 ms 212 KB Output is correct
11 Correct 6 ms 212 KB Output is correct
12 Correct 6 ms 212 KB Output is correct
13 Execution timed out 2061 ms 328 KB Time limit exceeded
14 Halted 0 ms 0 KB -