# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1000863 |
2024-06-18T10:31:08 Z |
변재우(#10901) |
Closing Time (IOI23_closing) |
C++17 |
|
42 ms |
27144 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<int, ll>> O;
void Update(int node, int s, int e, int k, ll v, ll sgn) {
Tree[node]+=v, 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]);
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
26972 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 |
42 ms |
9976 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
26968 KB |
Output is correct |
2 |
Correct |
3 ms |
26972 KB |
Output is correct |
3 |
Correct |
3 ms |
27144 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
2 ms |
24924 KB |
Output is correct |
6 |
Correct |
3 ms |
24924 KB |
Output is correct |
7 |
Correct |
3 ms |
24924 KB |
Output is correct |
8 |
Incorrect |
3 ms |
25092 KB |
1st lines differ - on the 1st token, expected: '74', found: '65' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
26968 KB |
Output is correct |
2 |
Correct |
3 ms |
26972 KB |
Output is correct |
3 |
Correct |
3 ms |
27144 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
2 ms |
24924 KB |
Output is correct |
6 |
Correct |
3 ms |
24924 KB |
Output is correct |
7 |
Correct |
3 ms |
24924 KB |
Output is correct |
8 |
Incorrect |
3 ms |
25092 KB |
1st lines differ - on the 1st token, expected: '74', found: '65' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
26968 KB |
Output is correct |
2 |
Correct |
3 ms |
26972 KB |
Output is correct |
3 |
Correct |
3 ms |
27144 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
2 ms |
24924 KB |
Output is correct |
6 |
Correct |
3 ms |
24924 KB |
Output is correct |
7 |
Correct |
3 ms |
24924 KB |
Output is correct |
8 |
Incorrect |
3 ms |
25092 KB |
1st lines differ - on the 1st token, expected: '74', found: '65' |
9 |
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: '6', found: '5' |
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: '6', found: '5' |
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: '6', found: '5' |
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: '6', found: '5' |
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: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |