QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#571577 | #9313. Make Max | hjx666 | WA | 101ms | 20920kb | C++14 | 5.4kb | 2024-09-18 00:45:59 | 2024-09-18 00:46:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define inv(x) ksm(x, mod - 2)
#define int long long
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define Yes cout << "Yes" << endl
#define lowbit(x) ((x) & (-x))
#define mem(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int ksm(int a, int b){int ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pair<int, int>, int> piii;
const int N = 2e5 + 5;
int dx[4] = {0, 1, -1, 0};
int dy[4] = {1, 0, 0, -1};
int n, m, k;
int a[N];
int b[N];
int c[N];
int d[N];
int jc[N];
int jcinv[N];
void solve()
{
cin >> n;
priority_queue < array<int, 3>, vector<array<int, 3>> , greater<array<int,3> >> s;
int maxn = 0;
for (int i = 1;i<=n;i++)
{
cin >> a[i];
s.push({a[i],i,i});
maxn = max(maxn, a[i]);
}
//cout << maxn << endl;
a[0] = 1e10;
a[n + 1] = 1e10;
s.push( {10000000000,0,0 } );
s.push( {10000000000,n+1,n+1 });
int sum = 0;
while(s.size()>2)
{
auto [v,l, r] = s.top();
//cout <<v<<" "<< l << " " << r << endl;
s.pop();
if(v==maxn)
break;
if(b[r]&&c[r]==1)
{
r = b[r];
b[r] = 0;
cout << 1 << endl;
}
if(b[l]&&c[l]==-1)
{
l = b[l];
b[l] = 0;
}
//cout << l << " " << r << endl;
int x = a[l - 1];
int y = a[r + 1];
if(x==1e10)
x = 0;
if(y==1e10)
y = 0;
//cout << l - 1 << " " << r + 1 << " ";
//cout << x << " " << y << endl;
if(y>=x)
{
if(y==v)
{
b[r + 1] = l;
//cout << 1 << endl;
}
else
b[r + 1] = l, sum += r - l + 1, a[l] = y, a[r] = y;
c[r + l] = -1;
}
else
{
if(x==v)
{
b[l - 1] = r;
}
else
b[l - 1] = r, sum += r - l + 1, a[l] = x, a[r] = x;
c[l - 1] = 1;
}
//cout << 11 << endl;
}
cout << sum << endl;
}
signed main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int t;
t = 1;
cin >> t;
while (t--)
solve();
}
/*
* ┌───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┐
* │Esc│ │ F1│ F2│ F3│ F4│ │ F5│ F6│ F7│ F8│ │ F9│F10│F11│F12│ │P/S│S L│P/B│ ┌┐ ┌┐ ┌┐
* └───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┘ └┘ └┘ └┘
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┬───┬───┐ ┌───┬───┬───┬───┐
* │~ `│! 1│@ 2│# 3│$ 4│% 5│^ 6│& 7│* 8│( 9│) 0│_ -│+ =│ BacSp │ │Ins│Hom│PUp│ │N L│ / │ * │ - │
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┼───┼───┤ ├───┼───┼───┼───┤
* │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │{ [│} ]│ | \ │ │Del│End│PDn│ │ 7 │ 8 │ 9 │ │
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ └───┴───┴───┘ ├───┼───┼───┤ + │
* │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │: ;│" '│ Enter │ │ 4 │ 5 │ 6 │ │
* ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ ┌───┐ ├───┼───┼───┼───┤
* │ Shift │ Z │ X │ C │ V │ B │ N │ M │< ,│> .│? /│ Shift │ │ ↑ │ │ 1 │ 2 │ 3 │ │
* ├─────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ ┌───┼───┼───┐ ├───┴───┼───┤ E││
* │ Ctrl│ │Alt │ Space │ Alt│ │ │Ctrl│ │ ← │ ↓ │ → │ │ 0 │ . │←─┘│
* └─────┴────┴────┴───────────────────────┴────┴────┴────┴────┘ └───┴───┴───┘ └───────┴───┴───┘
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5564kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 0 3 3
result:
ok 4 number(s): "1 0 3 3"
Test #2:
score: -100
Wrong Answer
time: 101ms
memory: 20920kb
input:
2 198018 875421126 585870339 471894633 383529988 625397685 944061047 704695631 105113224 459022561 760848605 980735314 847376362 980571959 329939331 644635272 326439858 752879510 837384394 175179068 182094523 397239381 1199016 185143405 279638454 252374970 822030887 860312140 137248166 993229443 164...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
wrong answer 1st numbers differ - expected: '4084978', found: '1'