版本比较
AT1275 Optimal Recommendations暴力题解
正文
增加 6 行删除 6 行
12345678910111213141517 行未改动33343536373839404111 行未改动53545556575859606116 行未改动78798081828384858617 行未改动1041051061071081091101111123 行未改动## 题目描述:在 $n$ 家公司中,每家公司有 3 个标准及工资,问:符合条件的 $m$ 人每人能达到的最大工资。## 题目分析首先看数据范围, $1≤N,M≤50000$。暴力时间复杂度为 $O(nm)$,但是我们可以先选择暴力+优化(~~万一~~能过)。### code:```cpp#include <bits/stdc++.h>using namespace std;struct info{int x,y,z,w;//x、y、z为三项能力,w为收入。}a[50005];int main()17 行未改动## 算法优化:* 首先加读入优化:```cppios::sync_with_stdio(0);```发现:再次超时。[提交记录](https://www.luogu.com.cn/record/83658212)11 行未改动举例:有人能力为```latex1 1 1```有 3 家公司| 2| 3| 4| 5|16 行未改动```cpp#include <bits/stdc++.h>using namespace std;struct info{int x,y,z,w;//x、y、z为三项能力,w为收入。}a[50005];bool cmp(info x,info y)17 行未改动{cout<<a[j].w<<endl;//输出收入。goto LOOP;//退出循环。}}cout<<0<<endl;//如果都进不了,输出0。LOOP:;}//暴力return 0;3 行未改动12345678910111213141517 行未改动33343536373839404111 行未改动53545556575859606116 行未改动78798081828384858617 行未改动1041051061071081091101111123 行未改动## 题目描述:在 $n$ 家公司中,每家公司有 3 个标准及工资,问:符合条件的 $m$ 人每人能达到的最大工资。## 题目分析首先看数据范围, $1≤N,M≤50000$。暴力时间复杂度为 $O(nm)$,但是我们可以先选择暴力+优化(~~万一~~能过)。### code:```cpp#include <bits/stdc++.h>using namespace std;struct info{int x,y,z,w;//x、y、z为三项能力,w为收入。}a[50005];int main()17 行未改动## 算法优化:* 首先加读入优化:```cppios::sync_with_stdio(0);```发现:再次超时。[提交记录](https://www.luogu.com.cn/record/83658212)11 行未改动举例:有人能力为```latex1 1 1```有 3 家公司| 2| 3| 4| 5|16 行未改动```cpp#include <bits/stdc++.h>using namespace std;struct info{int x,y,z,w;//x、y、z为三项能力,w为收入。}a[50005];bool cmp(info x,info y)17 行未改动{cout<<a[j].w<<endl;//输出收入。goto LOOP;//退出循环。}}cout<<0<<endl;//如果都进不了,输出0。LOOP:;}//暴力return 0;3 行未改动