#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pf push_front
#define ep emplace_back
#define ef emplace_front
#define len(a) *(&a+1)-a
// #define int long long
// #define ld long double
// #define mod 100ll000000007
#define stoi stoll
#define all(ls) ls.begin(),ls.end()
#define allr(ls) ls.rbegin(),ls.rend()
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
using namespace std;
using namespace __gnu_pbds;
template<typename type>using ordered_set=tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename type>using ordered_multiset=tree<type,null_type,less_equal<type>,rb_tree_tag,tree_order_statistics_node_update>;
struct custom_hash{
static uint64_t splitmix64(uint64_t x){
x+=0x9e3779b97f4a7c15;
x=(x^(x>>30))*0xbf58476d1ce4e5b9;
x=(x^(x>>27))*0x94d049bb133111eb;
return x^(x>>31);
}
size_t operator()(uint64_t x) const{
static const uint64_t FIXED_RAnDOM=chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x+FIXED_RAnDOM);
}
};
void solve(){
int n;
cin>>n;
// multiset<int>ms;
int ls[n][3],s[n],boost[n],k[n];
for(int i=0;i<n;i++){
s[i]=0;
k[i]=0;
boost[i]=0;
cin>>ls[i][0]>>ls[i][1]>>ls[i][2];
}
int m;
cin>>m;
int arr[m+1];
int dp[m+1][n];
memset(arr,0,sizeof(arr));
memset(dp,0,sizeof(dp));
for(int i=1;i<=m;i++){
cin>>arr[i];
for(int j=0;j<n;j++){
if(s[j]<=arr[i])
dp[i][j]=dp[i-1][j]+(max(0,(min(100,arr[i])-s[j]))*ls[j][0]+max(0,(min(200,arr[i])-max(100,s[j])))*ls[j][1]+max(0,arr[i]-max(200,s[j]))*ls[j][2]);
else
dp[i][j]=dp[i-1][j]-s[j]+arr[i];
k[j]=dp[i][j];
}
sort(k,k+n);
for(int j=0;j<n;j++)
boost[j]=(lower_bound(k,k+n,dp[i][j])-k)%20;
for(int j=0;j<n;j++){
if(s[j]<=arr[i]){
s[j]=arr[i]+boost[j];
dp[i][j]=dp[i][j]+boost[j];
}
else
dp[i][j]=dp[i-1][j];
}
}
for(int i=0;i<n;i++){
if(s[i]<=300){
dp[m][i]=dp[m][i]+(max(0,100-s[i])*ls[i][0]+max(0,200-max(100,s[i]))*ls[i][1]+max(0,300-max(200,s[i]))*ls[i][2]);
}
else
dp[m][i]=dp[m][i]-(s[i]-300);
cout<<dp[m][i]<<endl;
}
cout<<endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
cout.tie(nullptr);
// freopen("talent.in","r",stdin);
// freopen("talent.out","w",stdout);
int t=1;
// cin>>t;
while(t--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
21 ms |
1080 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
496 KB |
Output is correct |
11 |
Correct |
3 ms |
700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
21 ms |
1080 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
496 KB |
Output is correct |
16 |
Correct |
3 ms |
700 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
31 ms |
2612 KB |
Output is correct |
19 |
Correct |
68 ms |
3676 KB |
Output is correct |
20 |
Correct |
20 ms |
1116 KB |
Output is correct |
21 |
Correct |
128 ms |
6640 KB |
Output is correct |
22 |
Correct |
316 ms |
15848 KB |
Output is correct |
23 |
Correct |
331 ms |
24384 KB |
Output is correct |