QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#726070 | #9483. Maximize Array | nan01 | WA | 0ms | 3804kb | C++23 | 1.5kb | 2024-11-08 21:30:16 | 2024-11-08 21:30:17 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define ll long long
#define pii pair<int, int>
#define inf 0x3f3f3f3f
#define fi first
#define pll pair<ll, ll>
#define se second
#define lll __int128
#define ld long double
#define all(a) a.begin() + 1, a.end()
#define iofast \
ios::sync_with_stdio(false); \
cin.tie(0), cout.tie(0)
#define lowbit(i) (i & (-i))
using namespace std;
const int maxn = 1e6 + 5, mod = 1000000007;
void solve()
{
int n, k;
cin >> n >> k;
vector<int> a(n);
for (auto &i : a)
cin >> i;
vector<int> tong;
for (int i = 0; i < n; i += k)
{
tong.push_back(i - 1);
}
vector<bool> vis(n);
vector<int> b(n + 1);
for (int i = 0; i < k; i++)
{
vector<int> stk;
for (auto j : tong)
{
while (j + 1 < n && stk.size() && a[stk.back()] < a[j + 1])
{
b[stk.back()]++;
b[j + 1]--;
stk.pop_back();
}
if (j + 1 < n)
stk.push_back(j + 1);
}
tong.swap(stk);
}
for (int i = 0; i < n; i++)
{
if (i)
b[i] += b[i - 1];
if (!b[i])
{
cout << a[i] << " ";
}
}
cout << "\n";
}
int main()
{
iofast;
int t = 1;
// cin >> t;
while (t--)
solve();
// cout << endl;
// system("pause");
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
9 3 1 2 3 4 1 2 3 4 1
output:
4 4 1
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
6 1 1 6 4 2 3 5
output:
6 5
result:
ok 2 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
6 5 6 5 4 3 2 1
output:
6 5 4 3 2 1
result:
ok 6 tokens
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3804kb
input:
1392 5 915 798 656 1252 1170 691 1298 205 254 1334 622 1090 1081 617 365 477 362 1306 35 432 744 144 1277 259 80 410 317 983 916 1089 700 1030 135 156 1102 945 1021 63 251 1173 485 1261 1305 219 1190 151 142 288 795 984 1324 417 1235 1295 374 1091 434 596 553 1298 244 1179 115 767 973 315 603 180 10...
output:
1385 1279 719 828 749 1214 1089
result:
wrong answer 2nd words differ - expected: '1386', found: '1279'