답안 #526748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526748 2022-02-16T03:46:27 Z Hydroxic_Acid Izbori (COCI22_izbori) C++14
25 / 110
3000 ms 1484 KB
#include <iostream>
#include <cstring>
#include <map>
using namespace std;
#define ll long long

int n;
ll ways = 0;
int arr[200005];
int total[200005];
int highest = 0;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> arr[i];
    for(int l = 0; l < n; l++){
        memset(total, 0, sizeof(total));
        total[0] = n;
        highest = 0;
        map<int, int> m;
        for(int r = l; r < n; r++){
            total[m[arr[r]]]--;
            m[arr[r]]++;
            total[m[arr[r]]]++;
            if(highest < m[arr[r]]){
                highest = m[arr[r]];
                if(highest + highest > r - l + 1) ways++;
            }
            else if(total[highest] == 0){
                highest--;
            }
            else if(total[highest] == 1){
                if(highest + highest > r - l + 1) ways++;
            }
        }
    }

    cout << ways;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 988 KB Output is correct
2 Correct 2 ms 964 KB Output is correct
3 Correct 7 ms 976 KB Output is correct
4 Correct 9 ms 1068 KB Output is correct
5 Correct 7 ms 1076 KB Output is correct
6 Correct 7 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 988 KB Output is correct
2 Correct 2 ms 964 KB Output is correct
3 Correct 7 ms 976 KB Output is correct
4 Correct 9 ms 1068 KB Output is correct
5 Correct 7 ms 1076 KB Output is correct
6 Correct 7 ms 972 KB Output is correct
7 Correct 116 ms 1100 KB Output is correct
8 Correct 4 ms 972 KB Output is correct
9 Correct 113 ms 1068 KB Output is correct
10 Correct 110 ms 972 KB Output is correct
11 Correct 118 ms 1076 KB Output is correct
12 Correct 119 ms 1076 KB Output is correct
13 Correct 113 ms 1068 KB Output is correct
14 Correct 113 ms 1064 KB Output is correct
15 Correct 117 ms 972 KB Output is correct
16 Correct 109 ms 1072 KB Output is correct
17 Correct 59 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3066 ms 1484 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 988 KB Output is correct
2 Correct 2 ms 964 KB Output is correct
3 Correct 7 ms 976 KB Output is correct
4 Correct 9 ms 1068 KB Output is correct
5 Correct 7 ms 1076 KB Output is correct
6 Correct 7 ms 972 KB Output is correct
7 Correct 116 ms 1100 KB Output is correct
8 Correct 4 ms 972 KB Output is correct
9 Correct 113 ms 1068 KB Output is correct
10 Correct 110 ms 972 KB Output is correct
11 Correct 118 ms 1076 KB Output is correct
12 Correct 119 ms 1076 KB Output is correct
13 Correct 113 ms 1068 KB Output is correct
14 Correct 113 ms 1064 KB Output is correct
15 Correct 117 ms 972 KB Output is correct
16 Correct 109 ms 1072 KB Output is correct
17 Correct 59 ms 972 KB Output is correct
18 Execution timed out 3066 ms 1484 KB Time limit exceeded
19 Halted 0 ms 0 KB -