l佬们来看看 为啥RE

P1908 逆序对

jinhy_npu @ 2022-10-11 18:42:24

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,ans=0;long long s[100000000];
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>s[i];
    }
    for(long long j=1;j<=n;j++){
        for(long long k=j+1;j<=n;k++)
        {
            if(s[j]>s[k]){
                ans++;
            }
            else{
                ans+=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

屎山代码 求看看为啥RE


by AC_CSP @ 2022-10-11 18:43:15

for(long long k=j+1;j<=n;k++)


by jinhy_npu @ 2022-10-11 18:44:18

@AC_CSP 草 谢谢佬!Orz


by liruize2013 @ 2022-11-04 21:04:14

题说“请使用较快的输入输出”建议用scanf,printf 这样能节省将近100ms(毫秒)


by liruize2013 @ 2022-11-04 21:04:50

数据大的情况下


by liruize2013 @ 2022-11-04 21:05:12

@jinhy_npu


|