QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#196964#7228. Random Points on the CirclejeffqiAC ✓556ms50332kbC++201.7kb2023-10-02 05:36:102023-10-02 05:36:10

Judging History

你现在查看的是最新测评结果

  • [2023-10-02 05:36:10]
  • 评测
  • 测评结果:AC
  • 用时:556ms
  • 内存:50332kb
  • [2023-10-02 05:36:10]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define ui unsigned int
#define ull unsigned ll
#define i128 __int128
using namespace std;

namespace qiqi {
	const ll V = 1<<30;
	ll seed,add;
	ll get() {
		return seed = (seed*239017+add)%V;
	}
	void main() {
		int n,m;
		cin >> n >> m >> seed >> add;
		vll a(n*2),s(n*2+1);
		for (int i = 0; i < n; i++) {
			a[i] = get();
			a[i+n] = a[i]+V;
		}
		ranges::sort(a);
		for (int i = 0; i < n*2; i++) {
			s[i+1] = s[i]+a[i];
		}
		ll ans = *ranges::partition_point(views::iota(0ll,n*V+1),[&](ll x) {
			vll nxt(n*2);
			for (int l = 0,r = -1; l < n; l++) {
				auto calc = [&](int l,int r) {
					int mid = l+((r-l)>>1);
					return (mid-l)*a[mid]-(s[mid]-s[l])+(s[r]-s[mid])-(r-mid)*a[mid];
				};
				while (r < n*2 && calc(l,r+1) <= x) {
					r++;
				}
				nxt[l] = r;
				nxt[l+n] = nxt[l]+n;
			}
			pii mn(V,-1);
			for (int i = 0; i < n; i++) {
				mn = min(mn,pii(nxt[i]-i,i));
			}
			for (int i = mn.se; i <= nxt[mn.se]; i++) {
				for (int j = 0,p = i%n; j < m; j++) {
					p = nxt[p];
					if (p >= (i%n)+n) {
						return 0;
					}
				}
			}
			return 1;
		});
		cout << ans << '\n';
	}
}

int main() {
//	clock_t st = clock();
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int T = 1;
//	cin >> T;
	while (T--) {
		qiqi::main();
	}

//	cout << (double)(clock()-st)/CLOCKS_PER_SEC;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3844kb

input:

10 2
13 123

output:

626098570

result:

ok 1 number(s): "626098570"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

10 3
13 123

output:

302532222

result:

ok 1 number(s): "302532222"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

10 10
13 123

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

10 3
363606310 110949573

output:

322659618

result:

ok 1 number(s): "322659618"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

10 4
781726900 293540865

output:

180377100

result:

ok 1 number(s): "180377100"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

99 1
631536274 125123859

output:

25113339950

result:

ok 1 number(s): "25113339950"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

99 98
986776257 679440378

output:

10208

result:

ok 1 number(s): "10208"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

99 2
773705026 882748599

output:

6078581409

result:

ok 1 number(s): "6078581409"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

99 97
1066064403 735048522

output:

203934

result:

ok 1 number(s): "203934"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

99 3
790112566 236340147

output:

2661879431

result:

ok 1 number(s): "2661879431"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

99 96
1019591337 460365297

output:

440848

result:

ok 1 number(s): "440848"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

99 4
680758893 333382150

output:

1639918184

result:

ok 1 number(s): "1639918184"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

99 95
847357058 929132527

output:

358904

result:

ok 1 number(s): "358904"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

99 5
445644008 100132784

output:

988115184

result:

ok 1 number(s): "988115184"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

99 94
549361567 1067608389

output:

555789

result:

ok 1 number(s): "555789"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

100 10
84767911 610333873

output:

251560975

result:

ok 1 number(s): "251560975"

Test #17:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

1000 20
125604864 875792882

output:

663038720

result:

ok 1 number(s): "663038720"

Test #18:

score: 0
Accepted
time: 5ms
memory: 3740kb

input:

10000 10
671872425 790243593

output:

26718917867

result:

ok 1 number(s): "26718917867"

Test #19:

score: 0
Accepted
time: 2ms
memory: 3960kb

input:

10000 1000
649828772 353686006

output:

2742818

result:

ok 1 number(s): "2742818"

Test #20:

score: 0
Accepted
time: 5ms
memory: 3680kb

input:

10000 100
59473904 639861945

output:

267422367

result:

ok 1 number(s): "267422367"

Test #21:

score: 0
Accepted
time: 35ms
memory: 7580kb

input:

90000 10
1048291468 575029585

output:

241373453371

result:

ok 1 number(s): "241373453371"

Test #22:

score: 0
Accepted
time: 45ms
memory: 7536kb

input:

90000 9000
395055994 159188928

output:

306880

result:

ok 1 number(s): "306880"

Test #23:

score: 0
Accepted
time: 42ms
memory: 7448kb

input:

90000 300
247251128 466081796

output:

268548412

result:

ok 1 number(s): "268548412"

Test #24:

score: 0
Accepted
time: 158ms
memory: 20112kb

input:

360000 10
604876871 421966366

output:

965575496520

result:

ok 1 number(s): "965575496520"

Test #25:

score: 0
Accepted
time: 195ms
memory: 20280kb

input:

360000 36000
394191400 26842638

output:

76746

result:

ok 1 number(s): "76746"

Test #26:

score: 0
Accepted
time: 174ms
memory: 20092kb

input:

360000 600
688936536 354452435

output:

268440900

result:

ok 1 number(s): "268440900"

Test #27:

score: 0
Accepted
time: 451ms
memory: 50292kb

input:

1000000 10
415370459 331053934

output:

2680952049370

result:

ok 1 number(s): "2680952049370"

Test #28:

score: 0
Accepted
time: 556ms
memory: 50208kb

input:

1000000 100000
647234990 1030388958

output:

27624

result:

ok 1 number(s): "27624"

Test #29:

score: 0
Accepted
time: 542ms
memory: 50120kb

input:

1000000 1000
310788306 304973862

output:

268375390

result:

ok 1 number(s): "268375390"

Test #30:

score: 0
Accepted
time: 456ms
memory: 50332kb

input:

1000000 10
479772231 302292290

output:

2682252899276

result:

ok 1 number(s): "2682252899276"

Test #31:

score: 0
Accepted
time: 553ms
memory: 50120kb

input:

1000000 100000
80444941 1022344244

output:

27644

result:

ok 1 number(s): "27644"

Test #32:

score: 0
Accepted
time: 535ms
memory: 50080kb

input:

1000000 1000
186548259 317646077

output:

268389414

result:

ok 1 number(s): "268389414"