System Testing
0 / 96
CE
0/96 test cases passed
Submission #14
| Problem | NoQuickGrowth |
|---|---|
| Handle | nawa |
| Submitted | 2026-07-05 08:16:14 |
System Messages
main.cpp: In function 'int run_0()':
main.cpp:49:5: error: 'NoQuickGrowth' was not declared in this scope
49 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:50:15: error: 'obj' was not declared in this scope
50 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_1()':
main.cpp:62:5: error: 'NoQuickGrowth' was not declared in this scope
62 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:63:15: error: 'obj' was not declared in this scope
63 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_2()':
main.cpp:75:5: error: 'NoQuickGrowth' was not declared in this scope
75 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:76:15: error: 'obj' was not declared in this scope
76 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_3()':
main.cpp:88:5: error: 'NoQuickGrowth' was not declared in this scope
88 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:89:15: error: 'obj' was not declared in this scope
89 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_4()':
main.cpp:101:5: error: 'NoQuickGrowth' was not declared in this scope
101 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:102:15: error: 'obj' was not declared in this scope
102 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_5()':
main.cpp:114:5: error: 'NoQuickGrowth' was not declared in this scope
114 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:115:15: error: 'obj' was not declared in this scope
115 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_6()':
main.cpp:127:5: error: 'NoQuickGrowth' was not declared in this scope
127 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:128:15: error: 'obj' was not declared in this scope
128 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_7()':
main.cpp:140:5: error: 'NoQuickGrowth' was not declared in this scope
140 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:141:15: error: 'obj' was not declared in this scope
141 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_8()':
main.cpp:153:5: error: 'NoQuickGrowth' was not declared in this scope
153 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:154:15: error: 'obj' was not declared in this scope
154 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_9()':
main.cpp:166:5: error: 'NoQuickGrowth' was not declared in this scope
166 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:167:15: error: 'obj' was not declared in this scope
167 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_10()':
main.cpp:179:5: error: 'NoQuickGrowth' was not declared in this scope
179 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:180:15: error: 'obj' was not declared in this scope
180 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_11()':
main.cpp:192:5: error: 'NoQuickGrowth' was not declared in this scope
192 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:193:15: error: 'obj' was not declared in this scope
193 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_12()':
main.cpp:205:5: error: 'NoQuickGrowth' was not declared in this scope
205 | NoQuickGrowth obj;
| ^~~~~~~~~~~~~
main.cpp:206:15: error: 'obj' was not declared in this scope
206 | int got = obj.solve(a0, a1, a2, a3);
| ^~~
main.cpp: In function 'int run_13()':
main.cpp:218:5: error: 'NoQuickGrowth' was not declared in this sco
Source Code
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
class SequenceGrowing {
public:
int minShots(int N, int delta, int spread, int seed) {
// C will store the transformed sequence: C[i] = 10*i - A[i]
vector<long long> C(N);
long long state = seed;
long long mod_val = 1LL << 31; // 2^31
// 1. Generate the sequence A and simultaneously build C
for (int i = 0; i < N; ++i) {
// Pseudorandom generation
state = (state * 1103515245LL + 12345LL) % mod_val;
long long diff = state % (2LL * spread + 1);
long long A_i = 1LL * i * delta + diff - spread;
// Transform the sequence
C[i] = 10LL * i - A_i;
}
// 2. Find the length of the Longest Non-Decreasing Subsequence (LNDS) of C
vector<long long> tails;
for (int i = 0; i < N; ++i) {
// upper_bound finds the first element strictly greater than C[i].
// This is exactly what we need to maintain a non-decreasing subsequence.
auto it = upper_bound(tails.begin(), tails.end(), C[i]);
if (it == tails.end()) {
// If C[i] is larger than or equal to all elements, append it
tails.push_back(C[i]);
} else {
// Otherwise, overwrite the first element that is strictly greater
*it = C[i];
}
}
// 3. The minimum shots is total elements minus the elements we don't have to shoot
return N - tails.size();
}
};