QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#200637 | #5044. Happiness | xwb | RE | 132ms | 6896kb | C++20 | 4.3kb | 2023-10-04 18:07:32 | 2023-10-04 18:07:33 |
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 ;
vector<int> v ;
}q[N] ;
int f[N] , ff = 1e9 , fv = 0 ;
int a[N] ;
struct bi{
int f ;
int x , y ;
}t[15];
bool cmpp(vector<int>x,vector<int>y){
for(int i=0;i<min(x.size(),y.size());i++){
if(x[i]<y[i])return 1;
else if(x[i]>y[i])return 0;
}
if(x.size()<=y.size())return 1;
return 0;
}
bool cmp(ai a, ai b)
{
if(a.cnt == b.cnt)
if(a.s==b.s){
return cmpp(a.v,b.v);
}
else 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' ;
}
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) ;
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' ;
}
if(k < s.size() && s[k] == ' ')
{
cc ++ , ss += z ;
q[i].v.push_back(z);
f[p] = min(f[p] , z) ;
ff = min(ff , z) ;
fv = max(fv , z) ;
}
else
{
ss += z * 20 ;
}
j = k - 1 ;
}
}
q[i].s = ss , q[i].cnt = cc ;
sort(q[i].v.begin(),q[i].v.end());
}
sort(q + 1 , q + 1 + n - 1 , cmp) ;
fer(i,1,10) a[i] = i ;
get() ;
int happy=0;
do
{
vector<int>v;
int fa=0,guoti=0,time=0;
int th=0;
bool ok=0,okk=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 >= fv) okk = 1 ;
if(time<=f[a[i]])th+=800;
v.push_back(time);
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 ) || ( guoti == q[mid].cnt && fa == q[mid].s && cmpp(v,q[mid].v) )
) 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(okk==1)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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 126ms
memory: 6816kb
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: 132ms
memory: 6896kb
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
Runtime Error
input:
300 -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,-,- -,-,-,-,-,-,-,-,...