lyxleo @ 2021-02-10 23:23:18
求各位看看为什么输出出了问题,本地正常输出,测试没有输出。
#include <bits/stdc++.h>
#define array_N 100005
using namespace std;
long long n;
long long a[array_N];
long long t[array_N];
long long ans;
inline long long read(){
register long long w = 0,flag = 1;register char c = getchar();
while(c < 48 || c > 57){if(c == '-')flag = -1;c = getchar();}
while(c >= 48 && c <= 57) w = (w<<3) + (w<<1) + (c^48),c = getchar();
return flag*w;
}
inline long long print(long long x){
if(x < 0) putchar(45),x = -x;
if(x > 9) print(x/10);
putchar((x%10) + 48);
}
inline void function(long long l,long long r){
if(r - l < 1){
return;
}
long long mid = (l + r)/2;
function(l,mid);
function(mid+1,r);
int point1 = l,point2 = mid+1,point3 = 0;
while(point1 <= mid && point2 <= r){
if(a[point1] <= a[point2]){
t[point3] = a[point1];
++point1,++point3;
}
if(a[point1] > a[point2]){
t[point3] = a[point2];
++point2,++point3;
ans += mid - point1 + 1;
}
}
while(point1 <= mid){
t[point3++] = a[point1++];
}
while(point2 <= r){
t[point3++] = a[point2++];
}
for(int i=l,j = 0;i<=r;++i,++j){
a[i] = t[j];
}
return;
}
int main(){
n = read();
for(register long long i=0;i<n;++i){
a[i] = read();
}
function(0,n-1);
// for(int i=0;i<n;++i){
// printf("%d ",a[i]);
// }
print(ans);
}
by _caiji_ @ 2021-02-10 23:30:48
对于所有数据,
n\leq 5\times 10^5 。
#define array_N 100005
@lyxleo 您数组开小了
by lyxleo @ 2021-02-11 00:40:45
@caijianhong
谢谢,这是一个问题点。可是也不应该是“Too short on line one”的问题所在啊?
by Tom_Tucker @ 2021-02-12 15:40:00
您是不是语言选错了?我就曾选成了文言 我提交您的代码就AC了
by Tom_Tucker @ 2021-02-12 15:42:01
自动识别语言/c++