QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#450368#4629. Longest Increasing SubsequenceCrysflyWA 1ms5628kbC++141.5kb2024-06-22 11:05:322024-06-22 11:05:36

Judging History

你现在查看的是最新测评结果

  • [2024-06-22 11:05:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5628kb
  • [2024-06-22 11:05:32]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi; 

#define maxn 300005
#define inf 0x3f3f3f3f

int n,a[maxn];
int f[maxn][64],wei[64];
int go[64];

signed main(){
	n=read();
    For(i,1,n)a[i]=read();
    For(i,0,62) f[1][i]=1;
    go[0]=1;
    For(i,1,62) go[i]=(1ll<<(i-1));
    For(i,2,n){
        int t=a[i]-a[i-1];
        int now=0;
        For(j,0,62){
            int w=go[j];
            if(now+w<=t) now+=w;
            else {
                w=t-now,now+=w;
                if(w) 
                    cout<<"W: "<<j<<" "<<w<<" "<<now-w<<"\n",
                    f[i][j]=max(f[i][j],f[i-1][j-1]+max(1ll<<(j-1),w)+1);
            }
            wei[j]=w;
            f[i][j]=max(f[i][j],f[i-1][j]+w);
        }
        /*For(j,1,62){
            if((1ll<<j)>=t)break;
            if((1ll<<j)<t && (1ll<<(j+1))>=t)
                f[i][j]=max(f[i][j],f[i-1][j-1]+max(1ll<<(j-1),t-(1ll<<j))+((1ll<<(j+1))!=t));
        }*/
        For(j,1,62)f[i][j]=max(f[i][j],f[i][j-1]);
        //For(j,0,5) cout<<f[i][j]<<" "; cout<<"\n";
    }
    cout<<f[n][62];
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5628kb

input:

7
7 41 53 58 75 78 81

output:

W: 6 2 32
W: 4 4 8
W: 3 1 4
W: 5 1 16
W: 2 1 2
W: 2 1 2
34

result:

wrong answer 1st lines differ - expected: '22', found: 'W: 6 2 32'