답안 #5900

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
5900 2014-05-21T12:29:06 Z cki86201 역사적 조사 (JOI14_historical) C++
5 / 100
2960 ms 12540 KB
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<set>
using namespace std;

typedef long long ll;

int n, k, qu;
ll ans[100010];
ll p[100010];
map <ll,int> M;
set <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 : 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("%lld",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]] * p[L]);
        while(R<q[i].d)S.insert(++M[p[++R]] * p[R]);
        while(L<q[i].s)S.erase(M[p[L]]-- * p[L++]);
        while(R>q[i].d)S.erase(M[p[R]]-- * p[R--]);
		ans[q[i].c] = *(--S.end());
	}
	for(i=0;i<qu;i++)printf("%lld\n",ans[i]);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3960 KB Output is correct
2 Correct 0 ms 3960 KB Output is correct
3 Correct 0 ms 3960 KB Output is correct
4 Correct 0 ms 3960 KB Output is correct
5 Correct 0 ms 3960 KB Output is correct
6 Correct 0 ms 3960 KB Output is correct
7 Correct 0 ms 3960 KB Output is correct
8 Correct 0 ms 3960 KB Output is correct
9 Correct 0 ms 3960 KB Output is correct
10 Correct 0 ms 3960 KB Output is correct
11 Correct 0 ms 3960 KB Output is correct
12 Correct 0 ms 3960 KB Output is correct
13 Correct 0 ms 3960 KB Output is correct
14 Correct 0 ms 3960 KB Output is correct
15 Correct 0 ms 3960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3960 KB Output is correct
2 Correct 0 ms 3960 KB Output is correct
3 Correct 4 ms 3960 KB Output is correct
4 Correct 16 ms 3960 KB Output is correct
5 Correct 52 ms 4092 KB Output is correct
6 Incorrect 92 ms 4092 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3960 KB Output is correct
2 Correct 0 ms 3960 KB Output is correct
3 Correct 0 ms 3960 KB Output is correct
4 Correct 0 ms 3960 KB Output is correct
5 Correct 0 ms 3960 KB Output is correct
6 Correct 0 ms 3960 KB Output is correct
7 Correct 4 ms 3960 KB Output is correct
8 Correct 8 ms 4224 KB Output is correct
9 Correct 24 ms 4356 KB Output is correct
10 Correct 16 ms 4092 KB Output is correct
11 Correct 100 ms 3960 KB Output is correct
12 Correct 72 ms 4884 KB Output is correct
13 Correct 84 ms 4356 KB Output is correct
14 Correct 128 ms 6468 KB Output is correct
15 Correct 136 ms 7392 KB Output is correct
16 Correct 172 ms 12540 KB Output is correct
17 Incorrect 56 ms 5148 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 272 ms 4356 KB Output is correct
2 Correct 1168 ms 4884 KB Output is correct
3 Incorrect 2960 ms 5544 KB Output isn't correct
4 Halted 0 ms 0 KB -