QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546754 | #8218. 水镜 | chenxinyang2006 | 0 | 0ms | 3956kb | C++20 | 1.4kb | 2024-09-04 13:01:33 | 2024-09-04 13:01:33 |
answer
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;
template <class T>
void chkmax(T &x,T y){
if(x < y) x = y;
}
template <class T>
void chkmin(T &x,T y){
if(x > y) x = y;
}
inline int popcnt(int x){
return __builtin_popcount(x);
}
inline int ctz(int x){
return __builtin_ctz(x);
}
/*ll power(ll p,int k = mod - 2){
ll ans = 1;
while(k){
if(k % 2 == 1) ans = ans * p % mod;
p = p * p % mod;
k /= 2;
}
return ans;
}*/
int n;
int a[500005];
int check(int l,int r){
int pl = 0,pr = inf + inf;
rep(i,l + 1,r - 1){
if(a[i] <= min(a[i - 1],a[i + 1])) chkmin(pr,max(a[i] + a[i - 1],a[i] + a[i + 1]));
if(a[i] >= max(a[i - 1],a[i + 1])) chkmax(pl,min(a[i] + a[i - 1],a[i] + a[i + 1]));
}
return pl < pr;
}
int main(){
scanf("%d",&n);
rep(i,1,n) scanf("%d",&a[i]);
int l = 1;
ll answer = 0;
rep(r,1,n){
while(!check(l,r)) l++;
answer += r - l;
}
printf("%lld\n",answer);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 0ms
memory: 3836kb
input:
2 2 1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 7
Accepted
time: 0ms
memory: 3804kb
input:
10 2 2 2 2 1 4 5 3 3 2
output:
20
result:
ok 1 number(s): "20"
Test #3:
score: 7
Accepted
time: 0ms
memory: 3820kb
input:
10 2 2 1 2 2 2 1 4 1 4
output:
17
result:
ok 1 number(s): "17"
Test #4:
score: 7
Accepted
time: 0ms
memory: 3956kb
input:
10 1 5 2 2 5 4 4 4 1 3
output:
20
result:
ok 1 number(s): "20"
Test #5:
score: 0
Wrong Answer
time: 0ms
memory: 3856kb
input:
10 904418845477 67070474418 839309493679 528132965435 512894488193 602880026087 180594485896 804608714469 235337679831 584564033737
output:
26
result:
wrong answer 1st numbers differ - expected: '33', found: '26'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%