QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#283107#5693. 众数miaowuTL 0ms0kbC++23552b2023-12-13 20:42:162023-12-13 20:42:17

Judging History

你现在查看的是最新测评结果

  • [2023-12-13 20:42:17]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-12-13 20:42:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;
int n;
int arr[maxn];
set <int> s;
int ans;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> arr[i];
		if(arr[i])s.insert(i);
	}

	while(!s.empty()){
		set<int>::iterator it = s.end();
		ans += *(--it) * s.size();
		set <int> s2 = s;
		for(set<int>::iterator i = s2.begin(); i != s2.end(); ++i){
			if(--arr[*i])continue;
			s.erase(*i);
		}
	}

	cout << ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

99991
3 3 3 4 3 6 4 2 2 5 3 2 3 5 3 3 2 1 2 3 4 2 3 4 3 3 3 4 3 3 3 2 3 2 3 2 4 3 3 2 3 5 3 5 4 2 4 3 3 1 3 2 2 3 4 2 3 3 2 2 4 5 3 2 3 3 1 3 3 4 1 3 4 5 1 1 3 4 2 4 3 2 5 3 3 2 2 2 4 2 4 2 2 4 2 4 3 3 2 3 2 2 1 4 3 1 3 1 2 2 3 1 1 5 2 1 2 2 3 3 1 4 4 4 3 3 3 3 1 3 3 5 5 4 4 3 3 3 4 3 6 5 3 1 1 2 2 ...

output:


result: