結果
| 問題 |
No.956 Number of Unbalanced
|
| コンテスト | |
| ユーザー |
kmjp
|
| 提出日時 | 2019-12-19 00:15:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,033 bytes |
| コンパイル時間 | 1,605 ms |
| コンパイル使用メモリ | 169,272 KB |
| 実行使用メモリ | 8,564 KB |
| 最終ジャッジ日時 | 2024-07-06 23:04:00 |
| 合計ジャッジ時間 | 6,392 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 WA * 1 |
| other | AC * 10 WA * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N;
int A[101010];
vector<int> E[101010];
int C[101010];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
FOR(i,N) {
cin>>A[i];
E[A[i]].push_back(i);
}
ll ret=0;
FOR(x,N) {
int ma=0;
FOR(i,500) if(x+i<=N) {
C[A[x+i]]++;
ma=max(ma,C[A[x+i]]);
if(ma*2>i+1) ret++;
}
FOR(i,500) if(x+i<=N) C[A[x+i]]--;
}
cout<<ret<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
kmjp