社区讨论
加强数据or降黄
P1637三元上升子序列参与者 6已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @m2kc5l25
- 此快照首次捕获于
- 2024/10/22 19:01 去年
- 此快照最后确认于
- 2025/11/04 16:31 4 个月前
暴力可过
CPP#include <bits/stdc++.h>
using namespace std;
char *p1, *p2, buf[100000];
#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
inline int rd()
{
int x = 0, f = 1; char c = nc();
while (c < 48 || c > 57) f = (c == '-') ? -1 : 1, c = nc();
while (c >= 48 && c <= 57) x = x*10 + c-48, c = nc();
return x*f;
}
#define int long long
int n, a[30005], res;
signed main()
{
// freopen("P1637.txt", "r", stdin);
n = rd();
for (int i = 1; i <= n; ++i) a[i] = rd();
for (int k = 1; k <= n; ++k) {
int l = 0, r = 0;
for (int i = 1; i <= k - 1; ++i) if (a[i] < a[k]) ++l;
for (int j = k + 1; j <= n; ++j) if (a[j] > a[k]) ++r;
res += l * r;
}
printf("%lld\n", res);
return 0;
}
回复
共 5 条回复,欢迎继续交流。
正在加载回复...