답안 #520124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
520124 2022-01-28T12:56:48 Z ymm Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
324 ms 23304 KB
///
///   Oh? You're approaching me?
///

#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x,l,r) for(ll x = ll(r)-1; x >= ll(l); --x)
#define Kill(x) exit((cout << (x) << '\n', 0))
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
using namespace std;

const int N = 5e5+10;
const int M = 1e9+10;
int a[N];
vector<pair<pii,int>> vec;
int n, q;

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	cin >> n >> q;
	Loop(i,0,n) cin >> a[i];
	Loop(i,1,n) a[i] = min(M, a[i]%a[i-1]? a[i]+a[i-1]-(a[i]%a[i-1]): a[i]);
	for(int l=0,r=1;r<=n;++r){
		if(r==n||a[r]!=a[l]){
			vec.push_back({{-r, -l}, a[l]});
			l = r;
		}
	}
	while(q--){
		int l, r, t;
		cin >> t >> l >> r; ++r;
		int ans = l<=t&&t<r;
		for(auto [pr, x] : vec){
			auto [b, e] = pr;
			x = t-t%x;
			e = min(e+x, r);
			b = max(b+x, l);
			ans += max(0, e-b);
		}
		cout << ans << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 20848 KB Output is correct
2 Correct 209 ms 20732 KB Output is correct
3 Correct 230 ms 20668 KB Output is correct
4 Correct 207 ms 20644 KB Output is correct
5 Correct 213 ms 20736 KB Output is correct
6 Correct 217 ms 20680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 20848 KB Output is correct
2 Correct 209 ms 20732 KB Output is correct
3 Correct 230 ms 20668 KB Output is correct
4 Correct 207 ms 20644 KB Output is correct
5 Correct 213 ms 20736 KB Output is correct
6 Correct 217 ms 20680 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 239 ms 19392 KB Output is correct
14 Correct 211 ms 19868 KB Output is correct
15 Correct 222 ms 18460 KB Output is correct
16 Correct 218 ms 19016 KB Output is correct
17 Correct 306 ms 23268 KB Output is correct
18 Correct 295 ms 23304 KB Output is correct
19 Correct 296 ms 23248 KB Output is correct
20 Correct 303 ms 23268 KB Output is correct
21 Correct 294 ms 23300 KB Output is correct
22 Correct 282 ms 23280 KB Output is correct
23 Correct 295 ms 23196 KB Output is correct
24 Correct 292 ms 23256 KB Output is correct
25 Correct 224 ms 20712 KB Output is correct
26 Correct 227 ms 20680 KB Output is correct
27 Correct 308 ms 22800 KB Output is correct
28 Correct 317 ms 23292 KB Output is correct
29 Correct 324 ms 22792 KB Output is correct
30 Correct 309 ms 22816 KB Output is correct
31 Correct 298 ms 23244 KB Output is correct
32 Correct 236 ms 19404 KB Output is correct
33 Correct 0 ms 208 KB Output is correct