답안 #48075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48075 2018-05-10T03:12:42 Z duckmoon99 Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
1265 ms 262144 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector < pair<ll, ll> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll d[511111];
ll t[511111];
ll mov[511111];
vii a;

int main()
{
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL);
	//freopen("stress.txt","w",stdout);
	ll n, q;
	cin >> n >> q;
	t[0]=1;
	mov[0]=1;
	for(int i = 1; i <= n; i++){
		cin >> d[i];
	}
	ll idx=0;
	ll cnt=1;
	for(int i = 1; i <= n; i++){
		ll x = ((d[i]+mov[i-1]-1)/mov[i-1]);
		t[i]=x*t[i-1];
		mov[i]=x*mov[i-1];
		//cout << t[i] << " " << mov[i] << endl;
		if(x==1){
			cnt++;
		}
		else{
			if(t[idx]<=1e9){
				a.pb(mp(idx,cnt));
				idx=i;
				cnt=1;
			}
			else{
				i=n;
			}
		}
	}
	a.pb(mp(idx,cnt));
	ll T, L, R, l, r;
	for(int i = 0; i < q; i++){
		cin >> T >> L >> R;
		ll ans = 0;
		for(int j = 0; j < int(a.size()); j++){
			r = -(a[j].fi)+T/t[a[j].fi]*mov[a[j].fi];
			l = r-a[j].se+1;
			ans+=max(ll(0),min(R,r)-max(L,l)+1);
		}
		cout << ans << endl;
		
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1010 ms 30664 KB Output is correct
2 Correct 1016 ms 46128 KB Output is correct
3 Correct 1016 ms 61708 KB Output is correct
4 Correct 1208 ms 74752 KB Output is correct
5 Correct 1032 ms 74752 KB Output is correct
6 Correct 1014 ms 74752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 74752 KB Output is correct
2 Correct 4 ms 74752 KB Output is correct
3 Correct 4 ms 74752 KB Output is correct
4 Correct 4 ms 74752 KB Output is correct
5 Correct 6 ms 74752 KB Output is correct
6 Correct 4 ms 74752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1010 ms 30664 KB Output is correct
2 Correct 1016 ms 46128 KB Output is correct
3 Correct 1016 ms 61708 KB Output is correct
4 Correct 1208 ms 74752 KB Output is correct
5 Correct 1032 ms 74752 KB Output is correct
6 Correct 1014 ms 74752 KB Output is correct
7 Correct 4 ms 74752 KB Output is correct
8 Correct 4 ms 74752 KB Output is correct
9 Correct 4 ms 74752 KB Output is correct
10 Correct 4 ms 74752 KB Output is correct
11 Correct 6 ms 74752 KB Output is correct
12 Correct 4 ms 74752 KB Output is correct
13 Correct 1049 ms 88936 KB Output is correct
14 Correct 1053 ms 105532 KB Output is correct
15 Correct 1036 ms 120952 KB Output is correct
16 Correct 1050 ms 136560 KB Output is correct
17 Correct 1221 ms 156540 KB Output is correct
18 Correct 1211 ms 175300 KB Output is correct
19 Correct 1256 ms 193856 KB Output is correct
20 Correct 1192 ms 212392 KB Output is correct
21 Correct 1227 ms 231176 KB Output is correct
22 Correct 1204 ms 249812 KB Output is correct
23 Correct 1235 ms 262144 KB Output is correct
24 Correct 1244 ms 262144 KB Output is correct
25 Correct 1094 ms 262144 KB Output is correct
26 Correct 1049 ms 262144 KB Output is correct
27 Correct 1214 ms 262144 KB Output is correct
28 Correct 1229 ms 262144 KB Output is correct
29 Correct 1251 ms 262144 KB Output is correct
30 Correct 1241 ms 262144 KB Output is correct
31 Correct 1265 ms 262144 KB Output is correct
32 Correct 1035 ms 262144 KB Output is correct
33 Correct 2 ms 262144 KB Output is correct