Submission #1000866

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

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

class Seg {
public:
    void Clear() {
        for(auto [k, s]:O) Update(1, 1, Nt, lower_bound(C.begin(), C.end(), k)-C.begin()+1, k, -s);
        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, 1);
    }
    void Delete(ll k) {
        O.push_back({k, -1});
        Update(1, 1, Nt, lower_bound(C.begin(), C.end(), k)-C.begin()+1, k, -1);
    }
    int Query(ll k) {return Query(1, 1, Nt, k);}
private:
    ll Tree[2*Nt], Cnt[2*Nt];
    vector<pair<ll, int>> O;
    void Update(int node, int s, int e, int k, ll v, ll sgn) {
        Tree[node]+=v*sgn, Cnt[node]+=sgn;
        if(s==e) return;
        int lch=2*node, rch=lch+1, m=(s+e)/2;
        if(k<=m) Update(lch, s, m, k, v, sgn);
        else Update(rch, m+1, e, k, v, sgn);
    }
    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;
    fill(S+1, S+N+1, 0), C.clear();
    for(int i=2; i<=N; i++) S[i]=S[i-1]+W[i-2];
    for(int i=1; i<=N; i++) C.push_back(abs(S[i]-S[X])), C.push_back(abs(S[i]-S[Y]));
    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[l]-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 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 38 ms 10076 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 500 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 500 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 16 ms 600 KB Output is correct
20 Correct 19 ms 556 KB Output is correct
21 Correct 14 ms 348 KB Output is correct
22 Correct 11 ms 548 KB Output is correct
23 Correct 5 ms 348 KB Output is correct
24 Correct 5 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 500 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 16 ms 600 KB Output is correct
20 Correct 19 ms 556 KB Output is correct
21 Correct 14 ms 348 KB Output is correct
22 Correct 11 ms 548 KB Output is correct
23 Correct 5 ms 348 KB Output is correct
24 Correct 5 ms 468 KB Output is correct
25 Correct 14 ms 348 KB Output is correct
26 Execution timed out 1008 ms 1056 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -