QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#300930 | #5044. Happiness | Saanteye | WA | 165ms | 3428kb | C++17 | 5.5kb | 2024-01-09 01:22:55 | 2024-01-09 01:22:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> PII;
//#define p first
//#define d second
void solve(){
int n; cin >> n;
vector<string> s(n);
getchar();
for (int i = 0; i < n; i++) {
getline(cin,s[i]);
}
vector<vector<int>> sv(n, vector<int> (10));
vector<vector<int>> pl(n, vector<int> (10));
vector<int> ac(n), ple(n);
for (int i = 0; i < n; i++) {
int tim = 0, fs = -1, cnt = 0;
for (auto c:s[i]) {
if (c == '\n') continue;
else if (c == ' ') fs = 0;
else if (c >= '0' && c <= '9') {
if (fs != -1) fs = fs * 10 + c - '0';
else tim = tim * 10 + c - '0';
}
else if (c == ',') {
sv[i][cnt] = tim; pl[i][cnt] = fs;
if (fs == -1) sv[i][cnt] = 1e18;
cnt++; tim = 0; fs = -1;
}
}
sv[i][cnt] = tim; pl[i][cnt] = fs;
if (fs == -1) sv[i][cnt] = 1e18;
}
// for (int i = 0; i < n; i++) {
// for (int j = 0; j < 10; j++) {
// if (pl[i][j] == -1) cout << "- ";
// else
// cout << pl[i][j] << ' ';
// }
// cout << '\n';
// }
//for (int i = 0; i < n; i++)
// cout << sv[i][0] << '\n';
for (int i = 0; i < n - 1; i++)
for (int j = 0; j < 10; j++)
if (sv[i][j] != 1e18) {
ac[i]++;
ple[i] += sv[i][j] + pl[i][j] * 20;
}
//mi,mx,fb
int mi = 1e18, mx = -1e18;
vector<int> fb(10,1e18);
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < 10; j++) {
if (sv[i][j] == 1e18) continue;
fb[j] = min(fb[j],sv[i][j]);
mi = min(mi, sv[i][j]);
mx = max(mx, sv[i][j]);
}
sort(sv[i].begin(), sv[i].end());
}
vector<int> rk(n);
for (int i = 0; i < n; i++) rk[i] = i;
sort(rk.begin(), rk.end() - 1,[&](int a,int b){
if (ac[a] != ac[b]) return ac[a] > ac[b];
if (ple[a] != ple[b]) return ple[a] < ple[b];
for (int i = 0; i < 10; i++)
if (sv[a][i] != sv[b][i])
return sv[a][i] < sv[b][i];
return a < b;
});
// for (int i = 0; i < 10; i++)
// cout << fb[i] << ' ';
// return;
vector<int> ord(10);
iota(ord.begin(), ord.end(),0);
int ans = 0;
ac[n - 1] = -1e18; ple[n - 1] = 1e18;
do {
int now = 0, hap = 0;
int ov1 = 0, ove = 0;
vector<int> svl(10,1e18);
int rac = 0, rple = 0;
for (int i = 0; i < 10; i++) {
if (sv[n - 1][ord[i]] == 1e18) continue;
int rsv = sv[n - 1][ord[i]] + now;
now = rsv;
if (now > 300) continue;
rple += rsv + pl[n - 1][ord[i]] * 20;
rac += 1;
if (rsv <= fb[ord[i]]) hap += 800;
if (rsv <= mi) ov1 = 1;
if (rsv >= mx) ove = 1;
svl[ord[i]] = rsv;
}
sort(svl.begin(), svl.end());
if (ov1 && rac > 0) hap += 700;
if (ove && rac > 0) hap += 500;
// int l = -1, r = n;
// while (r - l > 1) {
// int mid = (r + l) >> 1;
// int idx = rk[mid];
// if (ac[idx] != rac) {
// if (ac[idx] > rac) l = mid;
// else r = mid;
// continue;
// } else if (ple[idx] != rple) {
// if (ple[idx] < rple) l = mid;
// else r = mid;
// continue;
// } else {
// int f = 0;
// for (int i = 0; i < 10; i++)
// if (sv[idx][i] != svl[i]) {
// if (sv[idx][i] > svl[i]) r = mid;
// else l = mid;
// f = 1;
// break;
// }
// if (!f) r = mid;
// continue;
// }
// }
// r += 1;
int r;
for (int i = 0; i < n; i++) {
if (ac[i] != rac) {
if (ac[i] < rac) r = i + 1;
break;
} else if (ple[i] != rple) {
if (ple[i] > rple) r = i + 1;
break;
} else {
int f = 1;
for (int j = 0; j < 10; j++)
if (sv[i][j] > svl[j]) {
f = 0;
break;
}
if (!f) { r = i + 1; break;}
}
}
// cout << rac << ' ' << rple << '\n';
hap += 5000 / r;
if (r <= n / 10) hap += 1200;
else if (r <= n / 10 * 3) hap += 800;
else if (r <= n / 10 * 6) hap += 400;
ans = max(ans, hap);
} while (next_permutation(ord.begin(),ord.end()));
cout << ans;
}
//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,-,-
signed main(){
// ios::sync_with_stdio(false);
// srand(time(0));
int _ = 1;
//cin >> _;
while(_--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 165ms
memory: 3428kb
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:
1300
result:
wrong answer 1st numbers differ - expected: '1800', found: '1300'