Submission #895776

# Submission time Handle Problem Language Result Execution time Memory
895776 2023-12-30T19:36:26 Z Isam Izbori (COCI22_izbori) C++17
10 / 110
3000 ms 1112 KB
#include<bits/stdc++.h>
using namespace std;
constexpr int sz = 500005;

signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N;
	cin >> N;
	vector<int> A(N);
	for(int &a : A) cin >> a;
	
	auto chk = [&](int l, int r){
		map<int, int> mp;
		for(register int i = l; i <= r; ++i) mp[A[i]]++;
		int that(0);
		for(auto &toto : mp) that = max(that, toto.second);
		return (that << 1) > (r - l + 1);
	};
	int ans(0);
	for(register int i = 0; i < N; ++i){
		for(register int j = i; j < N; ++j){
			ans += chk(i, j);
		}
	}
	cout << ans << '\n';
	
		
	
	
	
	
	
	/*
	2 2 1 2 3
	
	2;
	2;
	1;
	2;
	3;
	2 2;
	2 2 1;
	2 1 2;
	2 2 1 2;
	2 2 1 2 3;   	
	*/
	
	
	
	return 0;
}

Compilation message

Main.cpp: In lambda function:
Main.cpp:14:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |   for(register int i = l; i <= r; ++i) mp[A[i]]++;
      |                    ^
Main.cpp: In function 'int main()':
Main.cpp:20:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   20 |  for(register int i = 0; i < N; ++i){
      |                   ^
Main.cpp:21:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   21 |   for(register int j = i; j < N; ++j){
      |                    ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 31 ms 348 KB Output is correct
4 Correct 27 ms 348 KB Output is correct
5 Correct 27 ms 452 KB Output is correct
6 Correct 11 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 31 ms 348 KB Output is correct
4 Correct 27 ms 348 KB Output is correct
5 Correct 27 ms 452 KB Output is correct
6 Correct 11 ms 456 KB Output is correct
7 Execution timed out 3051 ms 348 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3009 ms 1112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 31 ms 348 KB Output is correct
4 Correct 27 ms 348 KB Output is correct
5 Correct 27 ms 452 KB Output is correct
6 Correct 11 ms 456 KB Output is correct
7 Execution timed out 3051 ms 348 KB Time limit exceeded
8 Halted 0 ms 0 KB -