QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#168762 | #5044. Happiness | absinthe# | WA | 531ms | 3544kb | C++20 | 4.3kb | 2023-09-08 21:19:18 | 2023-09-08 21:19:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<string> split(string s, char delim) {
vector<string> ret;
string cur;
for (auto i : s) {
if (i == delim) {
ret.push_back(cur);
cur = "";
continue;
}
cur += i;
}
ret.push_back(cur);
return ret;
}
void test() {
string inp;
getline(cin, inp);
int fs =-1;
int lastSubmisson = -1;
vector<int> firstSubmission(10, -1);
int n = stoi(inp);
vector<pair<pair<int, int>, vector<int>>> teams;
vector<pair<int, int>> bob(10);
for (int i = 0; i < n; i++) {
vector<int> times;
int penalty = 0;
getline(cin, inp);
vector<string> ret = split(inp, ',');
assert(ret.size() == 10);
int iter = 0;
int cnt = 0;
for (int i = 0; i < 10; i++) bob[i] = {-1, -1};
for (auto pp : ret) {
if (pp == "-"){
continue;
}
cnt += 1;
vector<string> ab = split(pp, ' ');
assert(ab.size() == 2);
int a = stoi(ab[0]);
int b = stoi(ab[1]);
times.emplace_back(a);
if (i + 1 < n) if (firstSubmission[iter] == -1 || firstSubmission[iter] > a) {
firstSubmission[iter] = a;
}
if (i + 1 < n) if(fs==-1||fs>a)fs=a;
if (i +1 < n) lastSubmisson = max(lastSubmisson, a);
bob[iter] = {a, b};
penalty += a;
penalty += b * 20;
iter += 1;
}
sort(begin(times), end(times));
reverse(begin(times), end(times));
teams.push_back({{-cnt, penalty}, times});
}
teams.pop_back();
sort(begin(teams), end(teams));
vector<int> order(10);
iota(begin(order), end(order), 0);
int ans = 0;
do {
int cnt = 0;
int curTime = 0;
int penalty = 0;
vector<int> times;
int myFirst = -1;
int myLast = -1;
int happy = 0;
for (auto i : order) {
if (bob[i].first == -1) continue;
if (curTime + bob[i].first > 300) continue;
cnt += 1;
curTime += bob[i].first;
penalty += curTime;
penalty += bob[i].second * 20;
times.emplace_back(curTime);
myLast = curTime;
if (firstSubmission[i] == -1 || curTime <= firstSubmission[i]) {
happy += 800;
}
if (myFirst == -1){
myFirst = curTime;
}
int inithappy = happy;
if(myFirst!=-1)if (fs==-1||myFirst <= fs) {
happy += 700;
}
sort(begin(times), end(times));
reverse(begin(times), end(times));
auto me = pair(pair(-cnt, penalty), times);
auto it = lower_bound(begin(teams), end(teams), me) - begin(teams);
it += 1;
if (it <= n / 10) {
happy += 1200;
} else if (it <= 3 * n / 10) {
happy += 800;
} else if (it <= 6 * n / 10) {
happy += 400;
}
if(myLast!=-1)if (myLast >= lastSubmisson) {
happy += 500;
}
happy += 5000/it;
ans = max(ans, happy);
happy = inithappy;
}
} while (next_permutation(begin(order), end(order)));
cout << ans << '\n';
// for (int i = 0; i < 10; i++) {
// cout << firstSubmission[i] << ' ';
// }
// cout << '\n';
// for (auto x : teams) {
// cout << -x.first.first << ' ' << x.first.second << '\n';
// }
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T=1;
// cin >> T;
while (T--) {
test();
}
}
/*
10
233 1,-,-,7 7,257 4,173 5,117 1,-,-,85 3
-,231 0,167 0,257 7,-,-,122 4,283 0,215 4,-
41 1,-,290 8,-,-,-,-,246 7,120 3,184 9
142 8,243 7,69 0,-,41 9,-,279 1,264 4,-,74 9
53 8,-,187 9,60 1,48 8,99 10,-,-,55 7,259 5
250 0,-,-,-,166 0,16 3,-,82 4,73 0,184 3
-,-,-,-,105 3,-,-,-,152 4,-
-,84 5,98 8,-,120 8,241 3,94 1,-,28 7,109 8
280 6,246 5,58 9,-,-,-,-,-,-,-
38 10,-,227 10,187 9,182 1,-,203 9,254 7,-,-
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 375ms
memory: 3460kb
input:
10 233 1,-,-,7 7,257 4,173 5,117 1,-,-,85 3 -,231 0,167 0,257 7,-,-,122 4,283 0,215 4,- 41 1,-,290 8,-,-,-,-,246 7,120 3,184 9 142 8,243 7,69 0,-,41 9,-,279 1,264 4,-,74 9 53 8,-,187 9,60 1,48 8,99 10,-,-,55 7,259 5 250 0,-,-,-,166 0,16 3,-,82 4,73 0,184 3 -,-,-,-,105 3,-,-,-,152 4,- -,84 5,98 8,-,1...
output:
1800
result:
ok 1 number(s): "1800"
Test #2:
score: 0
Accepted
time: 531ms
memory: 3476kb
input:
10 15 0,19 10,152 4,45 10,154 7,172 3,168 4,263 1,187 7,24 4 2 3,93 5,113 7,160 0,274 4,128 8,119 0,46 6,50 5,129 2 117 8,190 1,202 1,69 1,64 5,218 0,148 2,156 7,86 2,162 5 209 1,145 0,214 2,99 10,9 1,47 5,235 5,87 3,250 10,285 5 245 0,150 1,237 8,182 7,4 3,38 5,238 6,164 2,259 3,59 6 31 8,44 9,27 6...
output:
1300
result:
ok 1 number(s): "1300"
Test #3:
score: -100
Wrong Answer
time: 70ms
memory: 3544kb
input:
300 -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,...
output:
0
result:
wrong answer 1st numbers differ - expected: '6200', found: '0'