QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#567130#9313. Make MaxKagaMiku39WA 0ms3624kbC++14907b2024-09-16 08:19:532024-09-16 08:19:54

Judging History

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

  • [2024-09-18 15:56:24]
  • hack成功,自动添加数据
  • (/hack/836)
  • [2024-09-16 08:19:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2024-09-16 08:19:53]
  • 提交

answer

#include <iostream>
#include <unordered_map>
#include <algorithm>
using namespace std;
using ll = long long;

struct Node{
	ll cnt;
	int v;
};

unordered_map<ll, Node> s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t --) {
		unordered_map<ll, Node>().swap(s);
		int n; cin >> n;
		int p = 0;
		ll ans = 0;
		for (int i = 1; i <= n; i ++) {
			int v; cin >> v;
			ll cnt = 1;
			while (p > 1 && s[p - 1].v < v) {
				s[p - 1].cnt += s[p].cnt;
				ans += s[p].cnt;
				p --;
			}
			while (p && s[p].v <= v) {
				if (s[p].v != v) ans += s[p].cnt;
				cnt += s[p].cnt;
				p --;
			}
			cout << v << ' ' << cnt << ' ' << ans << endl;
			s[++ p] = Node{cnt, v};
		}
		if (p != 1) {
			int v = s[1].v;
			ll cnt = 0;
			while (p && s[p].v < v) {
				cnt += s[p].cnt;
				p --;
			}
		}
		cout << ans << '\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3624kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1 1 0
2 2 1
1
2 1 0
2 2 0
0
1 1 0
1 2 0
1 3 0
2 4 3
2 5 3
2 6 3
2 7 3
3
1 1 0
2 2 1
3 3 3
3

result:

wrong answer 2nd numbers differ - expected: '0', found: '1'