QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#450407 | #4629. Longest Increasing Subsequence | Crysfly | WA | 1ms | 5548kb | C++17 | 1.5kb | 2024-06-22 11:59:43 | 2024-06-22 11:59:46 |
Judging History
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 && j)
// cout<<"W: "<<j<<" "<<w<<" "<<now-w<<"\n",
f[i][j]=max(f[i][j],f[i-1][j-1]+max(w,1ll<<(j-1))+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;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5548kb
input:
7 7 41 53 58 75 78 81
output:
34
result:
wrong answer 1st lines differ - expected: '22', found: '34'