Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:事实证明:本题用longlong会wa,要用unsignedlong

Posted by yousiki at 2016-07-24 10:34:09 on Problem 3250
In Reply To:事实证明:本题用longlong会wa,要用unsignedlong Posted by:LittleKid at 2007-09-28 15:34:43
并没有这回事啊
#include<stack>
#include<bitset>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
signed main(void) {
	int n;
	long long ans = 0;
	stack< pair<int, int> > stk;
	scanf("%d", &n);
	for (int i = 1; i <= n + 1; i++) {
		int h = 0x3f3f3f3f;
		if (i <= n)scanf("%d", &h);
		while (stk.size() && stk.top().first <= h) {
			ans += i - stk.top().second - 1;
			stk.pop();
		}
		stk.push(make_pair(h, i));
	}
	printf("%lld\n", ans);
//	system("pause");
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator