답안 #197926

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197926 2020-01-24T09:37:14 Z AMO5 Worst Reporter 3 (JOI18_worst_reporter3) C++
12 / 100
2000 ms 8184 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

ll n,q,d[511111],chg[511111];

void upd(){
	ll ptr = d[1];
	for(ll i = 2; i <= n; i++){
		if(d[i]<=d[i-1]){
			chg[i] = 1;
		}
	}
	for(ll i = 1; i <= n; i++){
		if(chg[i])d[i] = d[i-1];
		else{
			ll cur = d[i]/ptr;
			if(d[i]%ptr)cur++;
			d[i] = ptr*cur;
			ptr = d[i];
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	cin >> n >> q;
	for(int i = 1; i <= n; i++)cin >> d[i];
	upd();
	ll ti,le,ri;
	//for(int i = 1; i <= n; i++)cout << d[i] << ' '; 
	//cout << endl;
	while(q--){
		cin >> ti >> le >> ri;
		ll ans = 0;
		if(ti>=le&&ti<=ri){
			ans++;
		}
		for(int i = 1; i <= n; i++){
			ll cur = ti/d[i];
			ll pos = -1*i + cur*d[i];
			if(pos>=le&&pos<=ri){
				ans++;
			}
			//cout << cur << ' ' << pos << ' ' << ans << endl;
		}
		cout << ans << endl;
	}
}	
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2001 ms 8184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 376 KB Output is correct
2 Correct 17 ms 376 KB Output is correct
3 Correct 19 ms 376 KB Output is correct
4 Correct 18 ms 376 KB Output is correct
5 Correct 19 ms 404 KB Output is correct
6 Correct 17 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2001 ms 8184 KB Time limit exceeded
2 Halted 0 ms 0 KB -