Submission #197919

# Submission time Handle Problem Language Result Execution time Memory
197919 2020-01-24T09:13:01 Z AMO5 Worst Reporter 3 (JOI18_worst_reporter3) C++
0 / 100
2000 ms 6392 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[500555],chg[500555];

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

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 = 0; i < n; i++)cin >> d[i];
	upd();
	ll ti,le,ri;
	for(int i = 0; i < n; i++)cout << d[i] << ' ';
	cout << endl;
	while(q--){
		cin >> ti >> le >> ri;
		ll ans = 0;
		if(ti>=le&&ti<=ri){
			ans++;
			//cout << "IOI-chan " << ti << endl;
		}
		for(int i = 0; i < n; i++){
			ll cur = ti/d[i];
			ll pos = -1*i + cur*d[i]-1;
			//cout << i+1 << ' ' << pos << ' ' << cur << endl;
			if(pos>=le&&pos<=ri){
				ans++;
				//cout << i+1 << ' ' << pos << endl;
			}
		}
		//cout << endl;
		cout << ans << endl;
	}
}	
# Verdict Execution time Memory Grader output
1 Execution timed out 2098 ms 6392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2098 ms 6392 KB Time limit exceeded
2 Halted 0 ms 0 KB -