QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#224473#7616. Jump Graphucup-team987#WA 0ms3872kbC++20786b2023-10-23 02:57:472023-10-23 02:57:48

Judging History

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

  • [2023-10-23 02:57:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2023-10-23 02:57:47]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
vector<long long>solve(const vector<int>&P)
{
	const int N=P.size();
	vector<long long>ret(N+1,0LL);
	vector<int>pos;
	for(int i=N;i--;)
	{
		while(!pos.empty()&&P[pos.back()]<P[i])
		{
			ret[pos.back()+1]-=i+1;
			pos.pop_back();
		}
		pos.push_back(i);
		ret[i+1]+=i+1;
	}
	for(int i=0;i<N;i++)ret[i+1]+=ret[i];
	ret.pop_back();
	return ret;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	vector<int>P(N);
	for(int i=0;i<N;i++)cin>>P[i];
	vector<long long>R=solve(P);
	reverse(P.begin(),P.end());
	vector<long long>L=solve(P);
	reverse(L.begin(),L.end());
	for(int i=0;i<N;i++)cout<<L[i]+R[i]<<(i+1==N?"\n":" ");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3872kb

input:

2
1 2

output:

1 1

result:

ok single line: '1 1'

Test #3:

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

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'