Submission #5910

# Submission time Handle Problem Language Result Execution time Memory
5910 2014-05-22T12:02:51 Z cki86201 역사적 조사 (JOI14_historical) C++
Compilation error
0 ms 0 KB
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<unordered_map>
#include<set>
using namespace std;

typedef long long ll;

int n, k, qu;
ll ans[100010];
int p[100010];
unordered_map <int,int> M;
multiset <ll> S;

struct qua{
	qua(){}
	qua(int s,int d):s(s),d(d){}
	int s, d, c;
	bool operator<(const qua &l)const{
		return d/k != l.d/k ? d/k < l.d/k : (((d/k)&1) ? s < l.s : s > l.s);
	}
}q[100010];

int main()
{
	scanf("%d%d",&n,&qu);
	k = int(sqrt(n));
	int i;
	for(i=1;i<=n;i++)scanf("%d",p+i);
	for(i=0;i<qu;i++)scanf("%d%d",&q[i].s,&q[i].d), q[i].c = i;
	sort(q,q+qu);
	int L = 1, R = 0;
	for(i=0;i<qu;i++){
		while(L>q[i].s)S.insert(++M[p[--L]] * (ll)p[L]);
		while(R<q[i].d)S.insert(++M[p[++R]] * (ll)p[R]);
		while(L<q[i].s)S.erase(S.find(M[p[L]]-- * (ll)p[L++]));
		while(R>q[i].d)S.erase(S.find(M[p[R]]-- * (ll)p[R--]));
		ans[q[i].c] = *S.rbegin();
	}
	for(i=0;i<qu;i++)printf("%lld\n",ans[i]);
	return 0;
}

Compilation message

In file included from /usr/include/c++/4.6/unordered_map:35:0,
                 from historic.cpp:4:
/usr/include/c++/4.6/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
historic.cpp:13:1: error: 'unordered_map' does not name a type
historic.cpp: In function 'int main()':
historic.cpp:35:29: error: 'M' was not declared in this scope
historic.cpp:36:29: error: 'M' was not declared in this scope
historic.cpp:37:33: error: 'M' was not declared in this scope
historic.cpp:38:33: error: 'M' was not declared in this scope
historic.cpp:27:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
historic.cpp:30:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
historic.cpp:31:60: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]