QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#614198#4629. Longest Increasing SubsequencebadmintonWA 0ms3752kbC++142.0kb2024-10-05 15:52:382024-10-05 15:52:39

Judging History

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

  • [2024-10-05 15:52:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3752kb
  • [2024-10-05 15:52:38]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;

#define forr(_a,_b,_c) for(int _a = (_b); _a <= int (_c); ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> int (_c);)
#define forf(_a,_b,_c) for(int _a = (_b); _a < int (_c); ++_a)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define mask(i) (1LL << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define bp __builtin_popcountll
#define file "test"

template<class X, class Y>
    bool minz(X &x, const Y &y) {
        if (x > y) {
            x = y;
            return true;
        } return false;
    }
template<class X, class Y>
    bool maxz(X &x, const Y &y) {
        if (x < y) {
            x = y;
            return true;
        } return false;
    }

const int N = 5e5 + 5;
const ll oo = (ll) 1e16;
const ll mod = 1e9 + 7; // 998244353;

ll n, a[N], f[70];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef hqm
        freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    #endif

    cin >> n;

    forr (i, 1, n){
        cin >> a[i];
    }


    forf (i, 1, n){
        ll u = (a[i + 1] - a[i] - 1), flag = 1;
        vector <ll> v{0};

        forr (j, 1, 61){
            if (u == 0){
                flag = 0;
                break;
            }
            if (u < mask(j)){
                v.pb(u);
                break;
            }
            u -= mask(j);
            v.pb(mask(j));
        }
        
        ford (i, v.size() - 1, 0){
         //   cout << v[i] << " ";
            ford (j, i, 0){
                maxz(f[i], f[j] + v[i] + (j == 0));
            }
        }

       // cout << "\n";

        forr (j, 1, 60)
            maxz(f[j], f[j - 1]);
    }

    cout << max (n, f[60]) << "\n";

    return 0;
}
/*



*/


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3752kb

input:

7
7 41 53 58 75 78 81

output:

22

result:

ok single line: '22'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

8
174 223 259 368 618 738 893 1810

output:

670

result:

wrong answer 1st lines differ - expected: '671', found: '670'