QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#789875 | #8936. Team Arrangement | BaseAI# | WA | 999ms | 3836kb | C++20 | 2.4kb | 2024-11-27 22:22:22 | 2024-11-27 22:22:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 67;
const int INF = 1e9;
int n;
int ans;
int w[N];
int num[N],numst[N];
bool vis[N];
vector<int> L[N];
int tot;
int sum[N]; //sum[x] l<=x 的个数
int suf[N]; //suf[x] r>=x 的个数
auto start = chrono::high_resolution_clock::now();
void Dfs(int rmn,int mx) {
auto stop = chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start).count();
if(duration > 998) {
cout << ans << "\n";
exit(0);
}
if(n-rmn > sum[mx]) return ; //已选的(l均小于等于x) 比线段多
if(rmn > suf[mx]) return ; //后选的(r均大于等于x) 比线段多
if(rmn == 0) {
//++tot;
set<int> st;
for(int i=1;i<=n;++i) numst[i] = 0;
bool flag = 1;
for(int i=1;i<=n;++i) {
for(auto r : L[i]) {
if(numst[r]==0)
st.insert(r);
++numst[r];
}
for(int j=0;j<num[i];++j) {
auto it = st.lower_bound(i);
if(it == st.end()) {
flag = 0; break;
} else {
int y = *it;
if(!--numst[y]) st.erase(it);
}
}
if(!flag) break;
}
if(flag) {
int val = 0;
for(int i=1;i<=n;++i) val += (num[i]/i)*w[i];
ans = max(ans, val);
}
return ;
}
if(rmn-mx+1 <= 0) return ;
vector<pair<int,int> > tmp(rmn-mx+1, make_pair(0, 0));
for(int i=0;i<rmn-mx+1;++i) {
tmp[i] = make_pair(-w[i+mx], i+mx);
}
sort(tmp.begin(), tmp.end());
for(auto [w, i] : tmp) {
// printf("i = %d\n",i);
num[i] += i;
Dfs(rmn-i, i);
num[i] -= i;
}
}
void solve() {
cin >> n;
for(int i=1;i<=n;++i) {
int l, r;
cin >> l >> r;
L[l].push_back(r);
sum[l]++;
suf[r]++;
}
for(int i=1;i<=n;++i) sum[i] += sum[i-1];
for(int i=n;i>=0;--i) suf[i] += suf[i+1];
for(int i=1;i<=n;++i) cin >> w[i];
ans = -INF;
Dfs(n, 1);
if(ans == -INF) cout << "impossible" << "\n";
else cout << ans << "\n";
// printf("tot = %d\n",tot);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
3 2 3 1 2 2 2 4 5 100
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
3 1 3 3 3 2 3 1 1 100
output:
100
result:
ok single line: '100'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 1 1 2 2 1 1
output:
impossible
result:
ok single line: 'impossible'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
3 2 3 1 2 2 2 -100 -200 100000
output:
-300
result:
ok single line: '-300'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
9 1 4 2 5 3 4 1 5 1 1 2 5 3 5 1 3 1 1 1 1 1 1 1 1 1 1 1
output:
6
result:
ok single line: '6'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
14 3 3 1 2 2 3 2 3 2 3 1 1 2 3 1 3 3 3 1 3 1 3 1 2 2 3 1 3 -9807452 -9610069 4156341 2862447 6969109 -7245265 -2653530 -5655094 6467527 -6872459 3971784 7312155 9766298 -2719573
output:
-16558567
result:
ok single line: '-16558567'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
14 1 2 1 4 2 3 3 5 4 5 2 5 2 4 2 4 1 2 3 4 1 5 2 4 1 1 4 5 -13763 -7354207 1096407 -9063321 -4824546 -6275546 1258145 -5272834 -8631107 3581157 2320771 -7714508 8446625 -6816167
output:
-2673021
result:
ok single line: '-2673021'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
14 2 3 4 4 1 7 3 6 3 4 1 1 1 4 4 7 3 7 1 7 2 3 6 6 1 1 3 6 2923142 1686477 640352 2848353 9202543 -4441381 4866381 -3610520 8124124 -1372894 1111310 -7538627 466143 9937961
output:
5939733
result:
ok single line: '5939733'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
14 1 7 1 2 8 8 1 1 7 8 6 9 7 8 1 4 6 9 3 3 1 1 3 7 5 8 4 8 -7139089 6365816 -9893288 5936146 -2803918 -4961415 1495365 -2564851 -2630365 -8608883 5813455 -4005459 -8844054 6703783
output:
impossible
result:
ok single line: 'impossible'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
14 6 13 3 7 2 13 6 8 4 5 12 13 3 10 4 11 2 14 3 4 5 13 10 14 10 14 3 12 -8599727 -1496394 855072 -7439122 -5170228 8009298 -250221 5841035 2949765 7166358 -3516548 -6851737 8173765 -917122
output:
impossible
result:
ok single line: 'impossible'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3620kb
input:
60 21 34 13 34 48 49 31 42 5 6 16 30 1 25 35 37 3 14 3 32 25 54 2 41 24 44 27 52 26 55 8 35 31 47 41 42 4 35 53 59 13 19 11 51 36 48 5 59 40 44 28 50 5 51 37 53 50 60 14 50 22 58 20 50 20 21 5 20 19 55 5 45 19 35 7 29 5 53 25 33 19 51 37 41 13 29 12 24 13 40 10 22 1 5 22 32 14 42 11 41 16 60 35 43 3...
output:
impossible
result:
ok single line: 'impossible'
Test #12:
score: 0
Accepted
time: 62ms
memory: 3600kb
input:
60 4 11 1 7 8 24 2 18 11 26 6 18 5 26 5 11 6 21 17 30 9 22 1 29 7 14 9 18 23 26 3 28 3 14 4 16 7 18 2 3 8 8 10 20 8 29 5 28 5 7 16 19 16 18 8 11 5 28 12 21 8 20 8 27 9 23 15 28 1 4 6 27 10 15 10 20 2 7 4 21 9 23 23 25 20 23 19 29 16 25 12 15 3 27 3 9 1 26 9 11 12 14 14 24 16 22 7 7 9 26 24 29 3 27 1...
output:
impossible
result:
ok single line: 'impossible'
Test #13:
score: 0
Accepted
time: 240ms
memory: 3672kb
input:
60 2 4 15 18 1 17 3 10 11 19 3 14 14 14 9 10 9 15 1 17 10 17 3 9 4 10 6 10 7 14 3 20 20 20 5 14 1 9 3 17 10 14 3 13 8 15 9 13 5 9 2 16 4 9 9 19 13 18 4 20 8 19 13 18 9 11 11 14 8 17 7 11 1 11 5 7 10 12 3 8 8 18 9 20 11 19 1 16 1 17 3 20 3 3 2 10 7 7 4 18 8 16 5 7 16 20 1 5 10 15 9 11 2 6 11 19 6 16 ...
output:
impossible
result:
ok single line: 'impossible'
Test #14:
score: 0
Accepted
time: 65ms
memory: 3624kb
input:
60 1 3 1 3 3 5 2 6 5 5 2 5 5 6 1 5 3 6 6 6 2 6 2 2 2 3 1 6 2 4 2 3 1 3 4 5 2 4 5 5 3 5 3 5 1 5 2 6 3 6 1 6 1 4 3 3 2 2 1 6 2 3 2 6 4 6 5 5 1 6 2 3 1 2 4 4 2 5 1 4 4 4 4 6 2 6 2 3 2 4 1 2 1 4 3 6 2 5 2 6 1 1 1 5 5 6 3 6 1 2 3 5 5 6 5 6 1 6 3 4 -9765941 -9284625 -9136963 -1872925 -9334679 -67293 96416...
output:
-87758107
result:
ok single line: '-87758107'
Test #15:
score: 0
Accepted
time: 6ms
memory: 3832kb
input:
60 1 1 1 4 2 2 3 4 1 2 1 2 1 4 2 3 1 4 1 2 4 4 1 3 2 4 2 2 2 3 2 4 1 4 3 4 1 2 3 3 2 3 1 1 2 4 2 4 2 4 1 2 1 2 3 3 3 4 2 3 1 3 2 4 1 2 1 3 1 2 3 4 2 2 2 4 1 3 1 1 2 4 2 3 2 3 4 4 1 2 1 4 1 2 2 4 2 3 4 4 2 4 3 4 3 4 1 1 2 3 3 4 2 4 2 3 3 4 2 2 -8959736 5094365 2567070 -9106790 9323252 -7495337 818129...
output:
67209846
result:
ok single line: '67209846'
Test #16:
score: 0
Accepted
time: 726ms
memory: 3680kb
input:
60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 ...
output:
154133500
result:
ok single line: '154133500'
Test #17:
score: 0
Accepted
time: 726ms
memory: 3684kb
input:
60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 ...
output:
281129340
result:
ok single line: '281129340'
Test #18:
score: 0
Accepted
time: 728ms
memory: 3616kb
input:
60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 ...
output:
191361510
result:
ok single line: '191361510'
Test #19:
score: 0
Accepted
time: 733ms
memory: 3640kb
input:
60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 ...
output:
-1693012
result:
ok single line: '-1693012'
Test #20:
score: 0
Accepted
time: 730ms
memory: 3612kb
input:
60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 ...
output:
-354498
result:
ok single line: '-354498'
Test #21:
score: 0
Accepted
time: 731ms
memory: 3576kb
input:
60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 ...
output:
178078620
result:
ok single line: '178078620'
Test #22:
score: 0
Accepted
time: 728ms
memory: 3636kb
input:
60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 60 1 ...
output:
267872880
result:
ok single line: '267872880'
Test #23:
score: 0
Accepted
time: 823ms
memory: 3836kb
input:
60 1 60 2 55 5 60 5 55 3 58 1 57 5 57 3 57 2 55 4 55 3 57 1 57 1 56 3 60 5 57 1 55 4 60 2 60 3 58 1 55 5 56 2 60 2 59 2 58 4 59 5 59 4 58 4 58 2 56 2 59 4 55 4 56 3 60 5 57 4 56 3 56 4 57 2 55 1 55 1 56 2 58 4 59 5 56 1 57 3 55 1 55 2 59 3 56 2 58 5 55 5 57 5 58 5 58 4 58 5 58 2 60 1 59 1 55 3 58 1 ...
output:
101249576
result:
ok single line: '101249576'
Test #24:
score: 0
Accepted
time: 583ms
memory: 3588kb
input:
60 4 57 2 57 3 56 5 52 2 59 9 50 4 60 7 52 3 57 4 56 7 59 1 52 8 59 7 53 1 50 4 56 9 52 6 54 5 53 3 55 7 52 2 56 4 57 1 54 2 51 8 58 7 50 8 52 4 53 4 50 3 52 2 51 7 58 9 59 2 54 3 56 8 53 8 59 1 55 4 58 4 56 5 50 4 57 3 50 3 56 3 59 2 50 10 52 10 53 8 60 8 50 4 51 6 55 3 54 3 51 10 53 1 58 6 54 8 54...
output:
84670208
result:
ok single line: '84670208'
Test #25:
score: 0
Accepted
time: 41ms
memory: 3672kb
input:
60 19 58 18 40 7 53 1 56 15 53 18 47 6 56 6 52 9 43 12 41 13 46 12 59 13 52 15 51 5 51 12 42 18 41 11 60 8 50 15 42 16 57 3 41 6 57 11 41 12 46 12 48 7 52 9 60 9 53 13 55 8 53 1 53 1 43 18 51 3 49 2 44 8 56 8 47 20 48 19 52 3 56 18 55 9 42 20 43 15 59 9 57 17 46 10 48 14 40 16 45 17 46 9 53 2 47 4 5...
output:
35924238
result:
ok single line: '35924238'
Test #26:
score: 0
Accepted
time: 21ms
memory: 3824kb
input:
60 8 44 25 53 22 41 14 38 9 40 8 36 4 44 13 52 12 55 19 40 16 55 4 55 22 51 12 57 16 45 11 48 18 55 11 35 13 39 8 52 20 42 15 47 2 57 15 36 9 48 23 52 5 60 20 56 4 35 14 44 1 57 8 46 3 53 12 55 21 44 14 60 17 47 3 57 10 58 1 43 2 39 4 43 19 51 10 48 19 56 17 45 22 36 14 58 9 52 20 58 3 41 2 38 3 36 ...
output:
39803807
result:
ok single line: '39803807'
Test #27:
score: 0
Accepted
time: 999ms
memory: 3560kb
input:
60 1 52 5 45 2 53 2 59 5 53 2 26 2 56 2 27 2 24 5 31 5 24 4 46 4 42 2 35 2 44 5 52 4 27 1 36 1 47 3 38 1 27 4 38 4 37 3 50 3 40 4 44 1 57 4 48 1 28 2 39 1 47 2 37 1 31 5 29 3 35 3 54 1 55 4 30 5 44 2 54 5 33 2 31 3 49 3 28 3 33 1 58 5 36 4 22 3 33 4 32 1 30 1 54 5 28 5 50 2 43 5 35 4 37 1 44 3 20 1 ...
output:
232766818
result:
ok single line: '232766818'
Test #28:
score: 0
Accepted
time: 999ms
memory: 3624kb
input:
60 1 41 1 28 2 24 1 33 3 55 5 32 5 26 3 31 1 22 1 43 3 27 1 36 5 45 1 55 1 22 2 24 4 26 3 52 2 58 2 32 3 59 3 46 4 33 5 59 5 42 2 46 3 49 4 40 5 40 4 21 3 45 5 47 5 42 5 44 2 56 4 29 5 52 3 43 5 23 1 49 4 38 2 20 4 31 1 49 2 24 3 48 5 52 2 36 3 44 4 48 5 44 4 34 4 47 1 51 5 47 3 23 3 40 5 38 5 52 1 ...
output:
-2774013
result:
ok single line: '-2774013'
Test #29:
score: 0
Accepted
time: 999ms
memory: 3784kb
input:
60 5 33 4 48 3 44 3 21 1 51 2 56 5 30 4 33 1 31 5 43 1 47 5 23 5 23 1 47 1 27 2 51 2 58 5 33 4 53 5 36 2 42 4 43 2 51 3 52 1 22 3 49 5 30 2 39 2 47 2 56 4 35 4 20 5 50 1 22 2 35 4 28 5 25 2 45 3 23 2 37 2 27 4 47 3 41 2 40 2 32 3 37 5 31 1 55 1 25 4 34 5 37 4 31 3 37 3 56 4 56 5 28 4 59 1 50 4 43 4 ...
output:
-3135271
result:
ok single line: '-3135271'
Test #30:
score: 0
Accepted
time: 999ms
memory: 3792kb
input:
60 4 52 2 58 4 33 1 39 5 59 1 52 3 44 5 57 5 54 4 46 4 36 3 42 1 50 1 37 3 20 4 24 3 48 2 58 1 33 5 47 2 27 3 24 4 37 3 57 2 52 2 56 3 45 2 24 4 35 3 23 2 21 4 52 4 44 4 54 3 51 2 49 1 46 5 49 2 25 5 58 5 44 4 42 5 23 5 57 3 38 4 60 1 46 2 36 5 48 2 40 5 28 4 45 3 35 3 50 4 25 3 27 5 55 3 57 3 51 2 ...
output:
193174547
result:
ok single line: '193174547'
Test #31:
score: -100
Wrong Answer
time: 999ms
memory: 3836kb
input:
60 2 33 2 52 5 45 1 49 3 33 5 39 3 22 5 22 1 44 5 31 4 37 2 28 5 26 2 56 2 40 1 45 5 27 1 46 1 52 2 59 2 49 4 38 1 50 3 60 1 32 1 22 2 57 2 58 4 21 3 46 4 31 3 50 5 31 4 35 3 38 2 41 3 37 4 40 2 46 3 55 5 31 5 34 1 31 5 55 3 29 5 48 3 22 1 32 2 57 2 43 3 24 3 59 3 31 5 51 5 31 2 24 2 43 1 23 2 30 4 ...
output:
189448435
result:
wrong answer 1st lines differ - expected: '202290067', found: '189448435'