Submission #242202

# Submission time Handle Problem Language Result Execution time Memory
242202 2020-06-27T05:32:01 Z errorgorn Worst Reporter 3 (JOI18_worst_reporter3) C++14
12 / 100
11 ms 1280 KB
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,q;
int arr[100005];

vector<ii> v; //{speed,num}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>q;
	
	rep(x,0,n) cin>>arr[x];
	
	v.push_back({1,1});
	
	rep(x,0,n){
		if (v.back().fi>=arr[x]){
			v.back().se++;
		}
		else{
			v.push_back({ceil((double)arr[x]/v.back().fi)*v.back().fi,1});
		}
	}
	
	ll t,l,r;
	while (q--){
		cin>>t>>l>>r;
		
		int prev=t;
		int curr=0;
		int ans=0;
		
		for (auto &it:v){
			int pos=-curr;
			int diff=prev-pos;
			pos+=diff/it.fi*it.fi;
			
			curr+=it.se;
			prev=pos-it.se;
			
			ii range={pos-it.se+1,pos};
			//cout<<range.fi<<" "<<range.se<<endl;
			
			if (range.se<l || r<range.fi) continue;
			ans+=min(r,range.se)-max(l,range.fi)+1;
		}
		
		cout<<ans<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -