QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#567184 | #9313. Make Max | y212 | WA | 15ms | 4112kb | C++14 | 2.1kb | 2024-09-16 09:43:35 | 2024-09-16 09:43:35 |
Judging History
answer
#include <bits/stdc++.h>
#define low(x) ((x) & (-(x) ) )
#define E(x) ((x) * (x))
#define ma make_pair
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
char ch1;
template<class T>
inline void rd(T& x) {
x = 0; bool w = 0;
ch1 = getchar();
while (!isdigit(ch1)) { ch1 == '-' && (w = 1), ch1 = getchar(); }
while (isdigit(ch1)) { x = (x << 1) + (x << 3) + (ch1 & 15), ch1 = getchar(); }
w && (x = (~x) + 1);
}
template<class T>
inline void wr(T x)
{
if (x < 0) x = -x, putchar('-');
if (x < 10) {
putchar(x + 48);
return;
}
T L = x / 10;
wr(L);
putchar(x - ((L << 1) + (L << 3)) + 48);
}
/*int head[N],tot;
struct edge{
int to,nxt;
}e[M];
void add(int u,int v){
e[++tot].to = v;
e[tot].nxt = head[u];
head[u] = tot;
}*/
bool cp(int a,int b){return a > b;} // С
int gcd(int a,int b){
if(b == 0)return a;
return gcd(b,a % b);
}
int T , n ;
LL ans ;
void sol() {
ans = 0;
cin >> n ;
int x ;
cin >> x ;
vector<int> a , v ;
a.push_back(x) ;
v.push_back(1) ;
rep(i,2,n) {
rd(x);
int m = a.size() ,cnt = 0 ,len = 0;
while(m) {
if(x > a.back()) {
cnt += v.back() ;
v.pop_back() ;
a.pop_back() ;
m -- ;
if(m == 0) a.push_back(x) , v.push_back(cnt + 1) , ans += cnt ;
}
else if(x == a.back()) {
v.back() += cnt + 1;
len = m - 1;
ans += len ;
break ;
}
else {
len = m ;
v.push_back(cnt + 1) ;
a.push_back(x) ;
ans += len ;
break ;
}
}
}
printf("%lld\n" , ans ) ;
}
int main(){
cin >> T ;
while(T --) sol() ;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
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: 15ms
memory: 4112kb
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:
2151880 2292908
result:
wrong answer 1st numbers differ - expected: '4084978', found: '2151880'