QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#594204 | #9313. Make Max | 02Ljh | WA | 60ms | 11708kb | C++14 | 2.5kb | 2024-09-27 20:16:06 | 2024-09-27 20:16:06 |
Judging History
answer
// 前を向け 終わらないさ
// 一生僕らは生きて征け
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ull unsigned long long
#define ll long long
#define WA cerr<<"meowww!\n";
#define eps 1e-5
#define none -1145141919
#define pii pair<int,int>
#define Y cout<<"Yes\n"
#define N cout<<"No\n"
#define H cout<<"\n";
#define WH cerr<<"\n";
#define fi first
#define se second
#define C continue;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
#define G(i,p) for(auto i:pq[p])
#define VG(i,p) for(int i=0;i<pq[p].size();i++)
#define pb push_back
#define pk pop_back
#define WR(x) cerr<<(x)<<"\n";
#define MAXN 200001
#define K cout<<" "
#define int long long
//const int MOD=;
//void MD(int &x) { if(x<0) x+=MOD; if(x>=MOD) x-=MOD; return ; }
void Umn(int &x,int y) { if(x>y) x=y; return ; }
void Umx(int &x,int y) { if(x<y) x=y; return ; }
int rd() { int x; cin>>x; return x; }
void wr(int x) { cout<<x; return ; }
int n; int ans=0;
int sz[MAXN],fa[MAXN];
int fd(int x) { if(x==fa[x])return x;
int nx=fd(fa[x]);return fa[x]=nx; }
int qwq[MAXN]; int cnt=0;
struct meow{int vl,id;}a[MAXN];
bool cmp(meow x,meow y) { return (x.vl==y.vl)?(x.id<y.id):(x.vl<y.vl); }
void mer(int x,int y,bool t) { int nx=fd(y);//cerr<<"FK="<<x<<" "<<y<<"\n";
if(t){ans+=sz[nx];}sz[nx]+=sz[x];fa[x]=nx; }
void pr(){For(i,1,cnt)cout<<fa[i]<<" ";H;For(i,1,cnt)cerr<<sz[i]<<" ";H;H;return ;}
bool v[MAXN];
main()
{
//freopen("in2.txt","r",stdin);
//freopen("out.txt","w",stdout);
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int _; cin>>_;
for(int __=1;__<=_;__++)
{int tot=0,lst=0,fr=-1;cnt=0;
ans=0; For(i,1,n) v[i]=0;
cin>>n; For(i,1,n) {cin>>qwq[i];a[i]={qwq[i],i};}//1 2 3 1 3 2
sort(a+1,a+1+n,cmp);//For(i,1,cnt){pq[]}
//For(i,1,cnt)cerr<<a[i].vl<<" "; H;
For(i,1,n) sz[i]=1,fa[i]=i;
For(i,1,n) {
int at=a[i].id;
if(at!=1&&qwq[at-1]<qwq[at]) { mer(at,at-1,1); }
if(at!=1&&qwq[at-1]==qwq[at]) { mer(at,at-1,0); }
if(at!=n&&qwq[at+1]<qwq[at]) { mer(at,at+1,1); }
}
cout<<ans<<"\n";
}
return 0;
}
/*
Need check before submit
1.INF=1e9 check if the val>=1e9 and only 0x3f3f3f3f and 0 can be memset!!!
2.Don't using getchar() unless is NESSASARY!!!
3.Enough size for the array!!!
4.Notice double's precision
5.CHECK UR LL OR ULL!!!
6.READ THE PROBLEM AGAIN AND AGAIN!!!
7.Check if for() is over int
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7676kb
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: 60ms
memory: 11708kb
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:
434179 417437
result:
wrong answer 1st numbers differ - expected: '4084978', found: '434179'