QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#200326 | #5044. Happiness | vanthoci# | WA | 73ms | 3772kb | C++17 | 4.3kb | 2023-10-04 16:27:01 | 2023-10-04 16:27:01 |
Judging History
answer
#include<bits/stdc++.h>
#define fer(i,a,b) for(int i = a ; i <= b ; i ++)
using namespace std;
const int N = 1e5 + 10 ;
int n ;
struct ai{
int s , cnt ;
}q[N] ;
int f[N] , ff = 1e9 , fv = 0 ;
int a[N] ;
struct bi{
int f ;
int x , y ;
}t[15];
/*
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,-,-
*/
bool cmp(ai a, ai b)
{
if(a.cnt == b.cnt)
return a.s < b.s ;
return a.cnt > b.cnt ;
}
void get()
{
string s ;
getline(cin , s) ;
int cc = 0 , ss = 0 , p = 1 ;
for(int j = 0 ; j < s.size() ; j ++)
{
if(s[j] == ',')
{
p ++ ;
}
else if(s[j] == '-')
{
t[p].f = 0 ;
}
else if(s[j] == ' ')
{
}
else
{
t[p].f = 1 ;
int z = 0 , k = j + 1 ;
while(k < s.size() && s[k] >= '0' && s[k] <= '9')
{
k ++ ;
}
fer(a , j , k - 1)
{
z = z * 10 + s[a] - '0' ;
}
//cout << z << '\n' ;
if(k < s.size() && s[k] == ' ')
{
t[p].x = z ;
}
else
{
t[p].y = z ;
}
j = k - 1 ;
}
}
}
void solve()
{
cin >> n ;
fer(i,1,10) f[i] = 1e9 ;
string s ;
getline(cin , s) ;
fer(i,1,n-1)
{
getline(cin , s) ;
//cerr << s << '\n' ;
int cc = 0 , ss = 0 , p = 1 ;
for(int j = 0 ; j < s.size() ; j ++)
{
if(s[j] == ',')
{
p ++ ;
}
else if(s[j] == '-')
{
}
else if(s[j] == ' ')
{
}
else
{
int z = 0 , k = j + 1 ;
while(k < s.size() && s[k] >= '0' && s[k] <= '9')
{
k ++ ;
}
fer(a , j , k - 1)
{
z = z * 10 + s[a] - '0' ;
}
//cout << z << '\n' ;
if(k < s.size() && s[k] == ' ')
{
cc ++ , ss += z ;
f[p] = min(f[p] , z) ;
ff = min(ff , z) ;
fv = max(fv , z) ;
}
else
{
ss += z * 20 ;
}
j = k - 1 ;
}
}
q[i] = {ss , cc} ;
//cout << cc << " " << ss << '\n' ;
}
sort(q + 1 , q + 1 + n - 1 , cmp) ;
fer(i,1,10) a[i] = i ;
get() ;
int happy=0;
do
{
int fa=0,guoti=0,time=0;
int th=0;
bool ok=0;
fer(i,1,10)
{
bi j = t[a[i]] ;
if(j.f){
time+=j.x;
if(time>300)
{
time -= j.x ;
break ;
}
if(time<=ff)ok=1;
if(time<=f[a[i]])th+=800;
guoti++;
fa+=j.y*20;
fa+=time;
}
}
if(ok)th+=700;
int l = 1 , r = n ;
while(l < r)
{
int mid = l +r >> 1 ;
if( guoti > q[mid].cnt || (guoti == q[mid].cnt
&& fa <= q[mid].s)
) r = mid ;
else l = mid + 1 ;
}
th+=5000/r;
if(r<=n/10){
th+=1200;
}
else if(r<=n/10*3){
th+=800;
}
else if(r<=n/10*6){
th+=400;
}
if(time>=fv)th+=500;
happy=max(happy,th);
} while (next_permutation(a + 1 , a + 1 + 10));
cout<<happy<<'\n';
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 34ms
memory: 3612kb
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: 31ms
memory: 3764kb
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: 73ms
memory: 3772kb
input:
300 -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,...
output:
6700
result:
wrong answer 1st numbers differ - expected: '6200', found: '6700'