P16401 [ECUSTPC 2026 Spring]

题解 : P16401 [ECUSTPC 2026 Spring] 星露谷物语

分两类讨论,取最大值即可。注意第 k+1k+1 天作物会枯萎,所以收获时间必须 k\le k

  1. 单次作物:只有售价 >> 进价才种。第 11 天种,第 1+t1+t 天收,收完马上重种。最大次数 c=k1tc = \lfloor \frac{k-1}{t} \rfloor,总利润 c×(qp)c \times (q-p)
  2. 持续作物:只买一次种子。第 1+t1+t 天首收,之后每 ss 天收一次。最大次数 c=1+k1tsc = 1 + \lfloor \frac{k-1-t}{s} \rfloor,总利润 c×qpc \times q - p

注意开 long long

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
int n,m;
ll k,ans=0;
cin>>n>>m>>k;
for(int i=0;i<n;i++){
ll p,q,t;
cin>>p>>q>>t;
if(k>t&&q>p){
ll c=(k-1)/t;
ans=max(ans,c*(q-p));
}
}
for(int i=0;i<m;i++){
ll p,q,t,s;
cin>>p>>q>>t>>s;
if(k>t){
ll c=1+(k-1-t)/s;
ans=max(ans,c*q-p);
}
}
cout<<ans<<"\n";
}
int main(){
int T;
cin>>T;
while(T--)solve();
}

P16401 [ECUSTPC 2026 Spring]
https://ywrow.github.io/2026/05/01/P16401-ECUSTPC-2026-Spring/
Beitragsautor
ywrow
Veröffentlicht am
2026年5月1日
Urheberrechtshinweis