Submission #1000892

# Submission time Handle Problem Language Result Execution time Memory
1000892 2024-06-18T10:58:54 Z 변재우(#10901) Closing Time (IOI23_closing) C++17
35 / 100
438 ms 132540 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() {
        fill(Tree, Tree+2*Nt, 0), fill(Cnt, Cnt+2*Nt, 0);
    }
    void Add(ll k) {
        O.push_back({k, 1});
        Update(lower_bound(C.begin(), C.end(), k)-C.begin()+1, k, 1);
    }
    void Delete(ll k) {
        O.push_back({k, -1});
        Update(lower_bound(C.begin(), C.end(), k)-C.begin()+1, k, -1);
    }
    void Update(int k, ll v, ll sgn) {
        for(k+=Nt-1; k; k>>=1) Tree[k]+=v*sgn, Cnt[k]+=sgn;
    }
    int Query(ll k) {return Query(1, 1, Nt, k);}
private:
    ll Tree[2*Nt], Cnt[2*Nt];
    vector<pair<ll, int>> O;
    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:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             if(s<=C.size()) return min(v/C[s-1], Cnt[node]);
      |                ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 860 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 40 ms 10068 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 1 ms 860 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 1 ms 860 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 2 ms 1240 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 2 ms 1116 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 4 ms 1116 KB Output is correct
19 Correct 8 ms 5580 KB Output is correct
20 Correct 13 ms 5320 KB Output is correct
21 Correct 15 ms 6724 KB Output is correct
22 Correct 11 ms 6344 KB Output is correct
23 Correct 7 ms 860 KB Output is correct
24 Correct 7 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 860 KB Output is correct
2 Correct 1 ms 860 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 2 ms 1240 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 2 ms 1116 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 4 ms 1116 KB Output is correct
19 Correct 8 ms 5580 KB Output is correct
20 Correct 13 ms 5320 KB Output is correct
21 Correct 15 ms 6724 KB Output is correct
22 Correct 11 ms 6344 KB Output is correct
23 Correct 7 ms 860 KB Output is correct
24 Correct 7 ms 860 KB Output is correct
25 Correct 25 ms 3024 KB Output is correct
26 Correct 364 ms 132468 KB Output is correct
27 Correct 268 ms 132540 KB Output is correct
28 Correct 260 ms 1812 KB Output is correct
29 Correct 438 ms 132540 KB Output is correct
30 Correct 339 ms 132540 KB Output is correct
31 Correct 107 ms 1116 KB Output is correct
32 Correct 111 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 860 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 1 ms 860 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 1 ms 860 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 1 ms 860 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 1 ms 860 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -