internet://debug https://www.aity012.com/live/all v8tm.com 73594216414550 https://dy.bolds.cn/vod/detail/179894/2/22 https://www.tdx.com.cn/soft.html https://groupweb.chaoxing.com/pc/resource/jumpToResourceList?bbsid=30d8d9ff-9ac3-4ba2-b957-99bfe56fe367 【探界先锋 安装+使用-哔哩哔哩】 https://b23.tv/jj9ztnf https://46dz.bgdy3.net/ https://fg8m.r8hr7.net/forum.php?mod=forumdisplay&fid=95&filter=lastpost&orderby=lastpost #include<bits/stdc++.h> #define int long long #define inf 1e18 #define mod 1000000007 using namespace std; const int maxn = 1e6 + 100; inline int read() { int x = 0 , f = 1; char ch = getchar(); while(ch < '0' || ch > '9' ) {if (ch == '-') f = -1; ch = getchar();} while(ch >= '0' && ch <= '9') {x = x * 10 + ch - 48; ch = getchar();} return x * f; } inline void write(int x) { if(x < 0) x = ~(x - 1) , putchar('-'); if(x > 9) write(x / 10); putchar(x % 10 + '0'); } inline void writeh(int x) { write(x); putchar('\n'); } inline void writek(int x) { write(x); putchar(' '); } int T , n , h[maxn] , a[maxn] , c[maxn] , cnt1 , cnt2; inline void work() { n = read(); cnt1 = cnt2 = 0; for(int i = 1; i <= n; ++i) h[i] = read(); bool flag = 0; for(int i = 2; i <= n; ++i) { if(h[i] != h[i - 1]) { flag = 1; break; } } if(!flag) { writeh(n / 2); return ; } sort(h + 1 , h + 1 + n); for(int i = 1; i <= n; i++) { if(h[i] != h[n / 2 + 1]) cnt1++; else break; } for(int i = n; i >= 1; --i) { if(h[i] != h[n / 2 + 1]) cnt2++; else break; } writeh(max(cnt1 * (n - cnt1) , cnt2 * (n - cnt2))); } signed main(){ freopen("graph.in" , "r" , stdin); freopen("graph.out" , "w" , stdout); T = read(); while(T--) work(); return !("wjl1100 qwq"); }
Note.ms
/yjm