蓝桥杯2018年第九届真题-递增三元组(二刷)
原题链接:
蓝桥杯2018年第九届真题-递增三元组 - C语言网 (dotcpp.com)https://www.dotcpp.com/oj/problem2194.htmlo(n3)+优化
o(n2)ac代码:
#include#includeusing namespace std;const int N = 100010;int a[N], b[N], c[N];int ans;int main(){int n; cin >> n;for (int i = 0; i > a[i];for (int i = 0; i > b[i];for (int i = 0; i > c[i];sort(a, a + n);sort(b, b + n);sort(c, c + n);for (int i = 0; i < n; i++) {for (int j = 0; j < n; j++) {if (a[i] < b[j]) {int k = 0;while (c[k] <= b[j]&&k<n) k++;if (k == n)continue;ans = ans + (n - k);}}}cout << ans << endl;}