版本比较
2026-7-16雅利模拟赛总结
正文
增加 117 行删除 11 行
41 行未改动424344454647484950215 行未改动全部展开26626726826927027127227327427579 行未改动35535635735835936036136236336436556 行未改动42242342442542642742842943043143243343443543643743843944044144244344444578 行未改动5245255265275285295305315325335345355365375383 行未改动5425435445455465475485495505519 行未改动41 行未改动char k;long long n , cnt=0;int main ( ){freopen ("cowtip.in" , "r" , stdin);freopen ("cowtip.out" , "w" , stdout);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);215 行未改动全部展开dfs (step+1 , sum);}int main ( ){// freopen ("air.in" , "r" , stdin);// freopen ("air.out" , "w" , stdout);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> n >> M;79 行未改动#### 本题总结要看数据范围来确定是否可以用暴力$Accepted$Berry Picking### T3:#### 本题得分:10分#### 开始时间:10时6分56 行未改动```#### 赛后题解#### 复杂度* 时间复杂度:$o(VN \cdot log2 (N))$* 空间复杂度:$o(N)$#### 补题代码```cpp```#### 本题总结### T4:Snow Boots#### 本题得分:10分78 行未改动```#### 赛后题解补题代码```cpp```#### 复杂度3 行未改动#### 本题总结## 四、整体反思### 做得较好的地方9 行未改动41 行未改动424344454647484950215 行未改动全部展开26626726826927027127227327427579 行未改动35535635735835936036136236336436556 行未改动42242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150278 行未改动5815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436443 行未改动6486496506516526536546556566579 行未改动41 行未改动char k;long long n , cnt=0;int main ( ){freopen ("cowtip.in" , "r" , stdin);freopen ("cowtip.out" , "w" , stdout);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);215 行未改动全部展开dfs (step+1 , sum);}int main ( ){freopen ("air.in" , "r" , stdin);freopen ("air.out" , "w" , stdout);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> n >> M;79 行未改动#### 本题总结要看数据范围来确定是否可以用暴力$Accepted$### T3:Berry Picking#### 本题得分:10分#### 开始时间:10时6分56 行未改动```#### 赛后题解不能用二分查找,必须枚举从$1 \sim 1000$所有的数,还要判断:$cnt<\frac{k}{2}$,$\frac{k}{2} \le cnt < k$,$k \le cnt$三种情况分类讨论#### 复杂度* 时间复杂度:$o(VN \cdot log2 (N))$* 空间复杂度:$o(N)$#### 补题代码```cpp#include <bits/stdc++.h>using namespace std;int p[1000005];int b[1005];int n , k , maxn=0;bool cmp (int x , int y){return x>y;}int check (int mid){int cnt=0;for (int i=1;i<=n;i++){cnt+=b[i]/mid;}return cnt;}int main ( ){freopen ("berries.in" , "r" , stdin);freopen ("berries.out" , "w" , stdout);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> n >> k;for (int i=1;i<=n;i++){cin >> b[i];}for (int i=1;i<=1000;i++){int cnt=check (i);if (cnt<k/2) continue;if (cnt>=k){maxn=max (maxn , i*(k/2));}else{memset (p , 0 , sizeof (p));for (int j=1;j<=n;j++){p[j]=b[j]%i;}sort (p+1 , p+n+1 , cmp);int sum=0;for (int j=1;j<=k-cnt;j++){sum+=p[j];}maxn=max (maxn , sum+i*(cnt-k/2));}}cout << maxn;return 0;}```#### 本题总结要分类的更完善防止有遗漏的分类讨论### T4:Snow Boots#### 本题得分:10分78 行未改动```#### 赛后题解$dp[i][j]$表示是否能用第$j$个靴子走到$i$,再通过扩散性来转移补题代码```cpp#include <bits/stdc++.h>using namespace std;int dp[251][251];int v[251] , s[251] , t[251];int n , m;int main ( ){freopen ("snowboots.in" , "r" , stdin);freopen ("snowboots.out" , "w" , stdout);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> n >> m;for (int i=1;i<=n;i++){cin >> v[i];}for (int i=1;i<=m;i++){cin >> s[i] >> t[i];}dp[1][1]=1;for (int i=1;i<=n;i++){for (int j=1;j<=m;j++){if (dp[i][j]==1){for (int k=j;k<=m;k++){for (int l=i+1;l<=min (n , i+t[k]);l++){if (v[i]<=s[k]&&v[l]<=s[k]){dp[l][k]=1;}}}}}}for (int i=1;i<=m;i++){if (dp[n][i]==1){cout << i-1;return 0;}}return 0;}```#### 复杂度3 行未改动#### 本题总结看到一个题不能不思考直接打暴力,有时候暴力思路都是错的,要去分析题目本质## 四、整体反思### 做得较好的地方9 行未改动