QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#225761#7616. Jump Graphucup-team484WA 0ms3876kbC++17976b2023-10-25 05:31:002023-10-25 05:31:00

Judging History

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

  • [2023-10-25 05:31:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3876kb
  • [2023-10-25 05:31:00]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

vector<ll> solve(int n, vector<int>& a) {
	vector<ll> s, ret(n, 0), b(n);
	auto upd = [&]() {
		int i = s.back();
		s.pop_back();
		ret[0] += b[i];
		ret[i] -= b[i];
		if (!s.empty())
			b[s.back()] += b[i];
	};
	for (int i = 0; i < n; i++) {
		while (sz(s) > 0 && a[s.back()] < a[i])
			upd();
		s.push_back(i);
		b[i]++;
	}
	while (sz(s) > 0)
		upd();
	for (int i = 1; i < n; i++)
		ret[i] += ret[i - 1];
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	auto x = solve(n, a);
	reverse(all(a));
	auto y = solve(n, a);
	for (int i = 0; i < n; i++)
		cout << x[i] + y[n - i - 1] << " \n"[i + 1 == n];
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3876kb

input:

6
1 6 3 2 5 4

output:

11 7 7 7 6 8

result:

ok single line: '11 7 7 7 6 8'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

2
1 2

output:

1 1

result:

ok single line: '1 1'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3636kb

input:

36
9 29 1 3 14 31 24 21 10 18 22 16 8 7 15 12 17 19 25 28 27 34 11 6 32 4 20 13 2 35 23 26 33 36 30 5

output:

101 98 99 99 100 87 81 79 79 79 73 72 71 71 70 72 72 77 83 94 107 100 120 120 116 118 116 116 116 113 142 142 143 143 175 175

result:

wrong answer 1st lines differ - expected: '92 89 90 90 91 78 73 71 71 71 ...110 107 136 136 137 136 168 168', found: '101 98 99 99 100 87 81 79 79 7...116 113 142 142 143 143 175 175'