QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#370340 | #4089. 회의실 | seojinhyeong99 | 0 | 3ms | 4212kb | C++17 | 1.9kb | 2024-03-29 02:12:24 | 2024-03-29 02:12:25 |
answer
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
typedef pair<int, int> pi;
typedef long long ll;
long long int min_charge(int K, vector<int> S, vector<int>E, vector<int>W) {
int n, k;
n = S.size();
k = K;
vector<array<ll, 3>>v(n);
for (int i = 0; i < n; i++) {
v[i] = { S[i],E[i],W[i] };
}
sort(v.begin(), v.end());
vector<priority_queue<ll, vector<ll>, greater<ll>>>pq(n);
vector<ll>d(n);
ll sum = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (v[i][1] >= v[j][1]) {
pq[i].push(v[j][2]);
d[i] += v[j][2];
if (pq[i].size() > k) {
d[i] -= pq[i].top();
pq[i].pop();
}
}
}
}
vector<int>a(n);
for (int i = 0; i < n; i++) a[i] = i;
for (int i = 0; i < n; i++) {
auto& cur = v[i];
sum += cur[2];
int e = i - 1;
multiset<ll, greater<ll>>s;
s.insert(0);
for (int j = 0; j < i; j++) s.insert(d[j]);
ll mx = d[i];
for (int j = i; j >= 0; j--) {
if (v[j][1] < cur[0]) break;
if (v[j][1] > v[i][1]) continue;
while (e >= 0 && v[a[e]][1] >= v[j][0]) {
auto it = s.find(d[e--]);
s.erase(it);
}
ll base = *s.begin();
pq[i].push(v[j][2]);
d[i] += v[j][2];
if (pq[i].size() > k) {
d[i] -= pq[i].top();
pq[i].pop();
}
mx = max(mx, d[i] + base);
}
d[i] = mx;
sort(a.begin(), a.begin() + i, [&](int x, int y)->bool {
return v[x][1] < v[y][1];
});
//cout<<i<<" : "<<mx<<"\n";
}
ll ans = 0;
for (auto i : d) ans = max(ans, i);
return sum - ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 3788kb
input:
5 1 2 6 5 4 6 2 8 8 5 1 3 4 6 8 7
output:
gxr40gvcqh-MEETING-rga0zuq58u 12
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
1 1 260947663 693934985 986106006
output:
gxr40gvcqh-MEETING-rga0zuq58u 0
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
14 1 623816097 623816097 68434400 623816097 623816097 725559682 623816097 623816097 678758318 623816097 623816097 368499632 623816097 623816097 495567409 623816097 623816097 236794280 623816097 623816097 779885584 623816097 623816097 879061467 623816097 623816097 537101862 623816097 623816097 465992...
output:
gxr40gvcqh-MEETING-rga0zuq58u 5864098008
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
14 1 474097486 930251201 788591065 2688701 471061191 845510022 2688701 203686122 275418775 203686122 601081080 31535815 474097486 474097486 228315825 161901890 474097486 85031827 203686122 601081080 337856340 471061191 601081080 604276423 161332531 471061191 357335089 262608550 474097486 82141704 26...
output:
gxr40gvcqh-MEETING-rga0zuq58u 3746923312
result:
ok 2 lines
Test #5:
score: -10
Wrong Answer
time: 0ms
memory: 3768kb
input:
14 1 494186620 531108277 961242307 620452125 623567580 364091773 23975216 357841107 512604788 59502148 793676488 729004547 293504000 748896401 598615542 398747973 967374174 642479347 31019655 476793418 584205112 376644841 543109385 320093318 874414082 884558783 925710684 327711462 354634260 92343656...
output:
gxr40gvcqh-MEETING-rga0zuq58u 4454737188
result:
wrong answer 2nd lines differ - expected: '4831774383', found: '4454737188'
Subtask #2:
score: 0
Wrong Answer
Test #64:
score: 17
Accepted
time: 2ms
memory: 3852kb
input:
248 1 798307257 798307257 359993686 798307257 798307257 812363141 798307257 798307257 872983330 798307257 798307257 537223276 798307257 798307257 375626816 798307257 798307257 518196362 798307257 798307257 474572280 798307257 798307257 277617903 798307257 798307257 473712578 798307257 798307257 5366...
output:
gxr40gvcqh-MEETING-rga0zuq58u 119894782350
result:
ok 2 lines
Test #65:
score: -17
Wrong Answer
time: 2ms
memory: 4068kb
input:
248 1 106716204 134413027 820571410 639195985 658024378 685768282 22383466 885531934 273730628 106716204 885531934 67224076 106716204 885531934 984556051 151623368 527066675 495233434 106716204 538526558 54768332 134413027 538526558 885649153 106716204 885531934 467319104 508538911 527066675 2628753...
output:
gxr40gvcqh-MEETING-rga0zuq58u 126367129817
result:
wrong answer 2nd lines differ - expected: '123443346507', found: '126367129817'
Subtask #3:
score: 0
Wrong Answer
Test #88:
score: 32
Accepted
time: 3ms
memory: 4212kb
input:
248 135 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992812 806992812 1 806992...
output:
gxr40gvcqh-MEETING-rga0zuq58u 113
result:
ok 2 lines
Test #89:
score: -32
Wrong Answer
time: 2ms
memory: 3980kb
input:
248 40 377400510 615563728 1 533035619 865270129 1 320586735 587946481 1 432205649 615563728 1 320586735 615563728 1 723259390 723259390 1 467410161 587946481 1 467410161 467410161 1 533035619 587946481 1 533035619 615563728 1 377400510 723259390 1 432205649 865270129 1 320586735 377400510 1 3205867...
output:
gxr40gvcqh-MEETING-rga0zuq58u 165
result:
wrong answer 2nd lines differ - expected: '168', found: '165'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%