由于每个区域最低耗时不能低于k,排序后将第n+1个区域的耗时设为k,作为循环的终止条件 1#include <algorithm>2#include <cstdio>3usingnamespacestd;4intn,m,k,s;5structnode{6intt,c;7}a[100005];8boolcmp(node x,node y)9{10returnx.t>y.t;11}12intmain()13{14inti,j,x=0,y;15scanf("%d...
#include<bits/stdc++.h>usingnamespacestd;intn,m;structnn{intt;intc;booloperator<(constnn&other)const{returnt<other.t;}}arr[100001];boolcheck(intp){longlongsum=0;for(inti=n;i>0;--i){if(arr[i].t>p){sum+=(arr[i].t-p)*arr[i].c;}else{break;}}returnsum<=m;}intmain(){intl...
int main(){ int n, m, k; // n待开垦的区域数量 m资源总数 k每块区域的最少开垦天数 cin >> n >> m >> k; vector[HTML_REMOVED] count; vector[HTML_REMOVED] time; vector[HTML_REMOVED] c; time.push_back(0); c.push_back(0); for(int i = 1;i <= n;i) { int a, b; cin ...
csp202303-2垦田计划 100分代码:(如果用cin输入会超时,95分)卡时间过的,正确做法是用二分 #include <bits/stdc++.h>using namespace std;typedef long long int ll;const ll maxn = 100005;int n, m, k;pair<int, int> o[maxn];bool cmp(pair<int, int> a, pair<int, int> b){if (a.firs...