답안 #1000864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000864 2024-06-18T10:32:42 Z 변재우(#10901) 봉쇄 시간 (IOI23_closing) C++17
21 / 100
1000 ms 121960 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, 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++) 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[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]);
      |                ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 26972 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 40 ms 10064 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 26972 KB Output is correct
2 Correct 2 ms 24924 KB Output is correct
3 Correct 2 ms 22876 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 24924 KB Output is correct
6 Correct 3 ms 22876 KB Output is correct
7 Correct 3 ms 24924 KB Output is correct
8 Correct 3 ms 22876 KB Output is correct
9 Correct 3 ms 24924 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 26972 KB Output is correct
2 Correct 2 ms 24924 KB Output is correct
3 Correct 2 ms 22876 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 24924 KB Output is correct
6 Correct 3 ms 22876 KB Output is correct
7 Correct 3 ms 24924 KB Output is correct
8 Correct 3 ms 22876 KB Output is correct
9 Correct 3 ms 24924 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 27216 KB Output is correct
13 Correct 5 ms 23128 KB Output is correct
14 Correct 5 ms 25176 KB Output is correct
15 Correct 5 ms 25180 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 6 ms 26972 KB Output is correct
19 Correct 55 ms 28548 KB Output is correct
20 Correct 68 ms 28000 KB Output is correct
21 Correct 54 ms 24612 KB Output is correct
22 Correct 40 ms 28108 KB Output is correct
23 Correct 17 ms 1640 KB Output is correct
24 Correct 18 ms 1488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 26972 KB Output is correct
2 Correct 2 ms 24924 KB Output is correct
3 Correct 2 ms 22876 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 24924 KB Output is correct
6 Correct 3 ms 22876 KB Output is correct
7 Correct 3 ms 24924 KB Output is correct
8 Correct 3 ms 22876 KB Output is correct
9 Correct 3 ms 24924 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 27216 KB Output is correct
13 Correct 5 ms 23128 KB Output is correct
14 Correct 5 ms 25176 KB Output is correct
15 Correct 5 ms 25180 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 6 ms 26972 KB Output is correct
19 Correct 55 ms 28548 KB Output is correct
20 Correct 68 ms 28000 KB Output is correct
21 Correct 54 ms 24612 KB Output is correct
22 Correct 40 ms 28108 KB Output is correct
23 Correct 17 ms 1640 KB Output is correct
24 Correct 18 ms 1488 KB Output is correct
25 Correct 49 ms 23132 KB Output is correct
26 Execution timed out 1068 ms 121960 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 26972 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 26972 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 26972 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 26972 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 26972 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -