Submission #1000850

# Submission time Handle Problem Language Result Execution time Memory
1000850 2024-06-18T10:17:45 Z 변재우(#10901) Closing Time (IOI23_closing) C++17
0 / 100
42 ms 26972 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

const int Nmax=3010, Nt=(1<<23);
ll S[Nmax];
vector<ll> C;

class Seg {
public:
    void Clear() {
        for(auto [k, o]:O) Update(1, 1, Nt, lower_bound(C.begin(), C.end(), k)-C.begin()+1, k*(ll)o);
        O.clear();
    }
    void Add(ll k) {
        O.push_back({k, 1});
        Update(1, 1, Nt, lower_bound(C.begin(), C.end(), k)-C.begin()+1, k);
    }
    void Delete(ll k) {
        O.push_back({k, -1});
        Update(1, 1, Nt, lower_bound(C.begin(), C.end(), k)-C.begin()+1, -k);
    }
    int Query(ll k) {return Query(1, 1, Nt, k);}
private:
    ll Tree[2*Nt], Cnt[2*Nt];
    vector<pair<int, ll>> O;
    void Update(int node, int s, int e, int k, ll v) {
        Tree[node]+=v, Cnt[node]+=((v>0)?1:-1);
        if(s==e) return;
        int lch=2*node, rch=lch+1, m=(s+e)/2;
        if(k<=m) Update(lch, s, m, k, v);
        else Update(rch, m+1, e, k, v);
    }
    int Query(int node, int s, int e, ll v) {
        if(s==e) {
            if(s==1) return Cnt[node];
            if(s<=C.size()) return min(v/C[s-1], Cnt[node]);
            return 0;
        }
        int lch=2*node, rch=lch+1, m=(s+e)/2;
        if(Tree[lch]<=v) return Cnt[lch]+Query(rch, m+1, e, v-Tree[lch]);
        else return Query(lch, s, m, v);
    }
}T;

int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
    X++, Y++;
    int ans=0;
    for(int i=2; i<=N; i++) S[i]=S[i-1]+W[i-2];
    for(int i=1; i<=N; i++) for(int j=i; j<=N; j++) C.push_back(S[j]-S[i]);
    sort(C.begin(), C.end()); C.erase(unique(C.begin(), C.end()), C.end());
    ll sum=0;
    for(int r=X; r<=N; r++) {
        ll tsum=sum;
        T.Clear();
        for(int i=X-1; i>=1; i--) T.Add(S[X]-S[i]);
        for(int i=Y+1; i<=N; i++) {
            if(i>r) T.Add(S[i]-S[Y]);
            else T.Add(0);
        }
        for(int l=Y; l>=1; l--) {
            sum+=(S[Y]-S[l]);
            if(X<=l && l<=r) sum-=min(S[Y]-S[l], S[r]-S[X]);
            if(l<X) T.Delete(S[X]-S[l]), T.Add(0);
            if(sum<=K) ans=max(ans, r-X+1+Y-l+1+T.Query(K-sum));
        }
        sum=tsum+S[r+1]-S[X];
    }
    return ans;
}

Compilation message

closing.cpp: In member function 'int Seg::Query(int, int, int, ll)':
closing.cpp:38:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             if(s<=C.size()) return min(v/C[s-1], Cnt[node]);
      |                ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 26972 KB 2nd lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 13544 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 26972 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 26972 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 26972 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 26972 KB 2nd lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 26972 KB 2nd lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 26972 KB 2nd lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 26972 KB 2nd lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 26972 KB 2nd lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -