답안 #572035

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572035 2022-06-03T11:33:11 Z beaconmc 말 (IOI15_horses) C++14
54 / 100
160 ms 29652 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
typedef long long ll;

#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
#define double long double
#define SIZE 1048576
#define HSIZE 524288
#define MOD 1000000007
// #include "horses.h"
using namespace std;

vector<ll> x, y, xx, yy;
ll n;


ll tree[SIZE];

void update(ll a,ll b){
    a += HSIZE;
    tree[a] = b;
    while (a>1){
        a/=2;
        tree[a] = tree[a*2]*tree[a*2+1]%MOD;
    }
}

ll query(ll a, ll b){
    a += HSIZE;
    b += HSIZE;
    ll maxi = 1;
    while (a<=b){
        if (a%2==1){
            maxi *= tree[a++]; 
            maxi %= MOD;
        }
        if (b%2==0){
            maxi *= tree[b--];
            maxi %= MOD;
        }
        a/=2; b/=2;
    }
    return maxi;
}



int solve(){
	ll maxsum = 1;
	ll maxpos = -1;
	ll cur = 1;
	if (n<=1000){
		FOR(i,0,n){
			cur *= x[i];
			if (y[i] * cur >= maxsum){
				cur = 1;
				maxsum = y[i];
				maxpos = i;
			}
		}
	}
	else{
		FOR(i,n-35,n){
			cur *= x[i];
			if (y[i] * cur >= maxsum){
				cur = 1;
				maxsum = y[i];
				maxpos = i;
			}
		}
	}


	


	return (query(0, maxpos) * maxsum) % 1000000007;

}

int init(int N, int X[], int Y[]) {
	n = N;
	FOR(i,0,N){
		x.push_back(X[i]);
		update(i, X[i]);
		y.push_back(Y[i]);
	}
	return solve();

}

int updateX(int pos, int val) {	
	update(pos, val);
	x[pos] = val;
	return solve();
}

int updateY(int pos, int val) {
	y[pos] = val;
	return solve();

}



// int main(){
// 	ll n = 10;
// 	int x[10] = {10, 10, 10, 10, 10, 10, 1, 1, 1, 1};
// 	int y[10] = {1, 1, 1, 1, 9, 5, 4, 7, 3, 2};

// 	cout << init(n, x, y) << endl;

// 	cout << updateX(5, 1) << endl;
// 	cout << updateY(5, 123456789) << endl;
// 	cout << updateX(5, 1) << endl;
// 	cout << updateX(8, 987654321) << endl;


// }

Compilation message

horses.cpp: In function 'int solve()':
horses.cpp:78:37: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   78 |  return (query(0, maxpos) * maxsum) % 1000000007;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 288 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 292 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 4 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 2 ms 400 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 408 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 21088 KB Output is correct
2 Correct 160 ms 21060 KB Output is correct
3 Correct 112 ms 21032 KB Output is correct
4 Correct 140 ms 21076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 4 ms 340 KB Output is correct
24 Correct 4 ms 400 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Incorrect 82 ms 20268 KB Output isn't correct
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 404 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 98 ms 22356 KB Output is correct
34 Correct 159 ms 29652 KB Output is correct
35 Correct 115 ms 22884 KB Output is correct
36 Correct 150 ms 25164 KB Output is correct
37 Incorrect 88 ms 21964 KB Output isn't correct
38 Halted 0 ms 0 KB -