日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

codeforces738C

發(fā)布時間:2023/12/29 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 codeforces738C 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

點擊打開鏈接

題意:

? ? ? ?

思路:?

? ? 一個車能不能選只和它的油箱容量有關(guān),所以按照油箱排序,找到一個合適的最小容量即可,再求一下最優(yōu)即可。

#include<iostream> #include<algorithm> #include<string> #include<cmath> #include<vector> #include<set> #include<map> #include<stack> #include<queue> #include<cstdio> #include<cstring> #define ll long long using namespace std;const int maxn = 2e5 + 10;int n, k, s, t, mint;struct node {int c, tank;friend bool operator < (node a, node b){return a.tank < b.tank;}}a[maxn];int g[maxn];bool check(int x) {int nowtank = a[x].tank;double tx = 1.0 * mint;for(int i = 1; i <= k; i++){nowtank = a[x].tank;int len = g[i] - g[i-1];if(len > nowtank)return false;else if(nowtank > 2*len)nowtank = 2*len;tx = tx - 1.0*(nowtank - len);}nowtank = a[x].tank;int len = s - g[k];if(len > nowtank)return false;else{if(nowtank > 2*len)nowtank = 2*len;tx = tx - 1.0*(nowtank - len);}if(tx>0)return false;elsereturn true; }int main() {scanf("%d%d%d%d", &n, &k, &s, &t);if(s > t){cout<<-1<<endl;return 0;}for(int i = 1; i <= n; i++){scanf("%d%d", &a[i].c, &a[i].tank);}for(int i = 1; i <= k; i++){scanf("%d", &g[i]);}sort(a+1, a+1+n);sort(g+1, g+k+1);mint = t-2*(t-s);int l = 0, r = n+1, mid;bool flag =false;while(l < r){mid = (l+r)/2;if(check(mid)){r = mid;flag = true;}elsel = mid+1;}int minc = 2e9;if(!flag){cout<<-1<<endl;return 0;}for(int i = r; i <= n; i++)minc = min (minc, a[i].c);printf("%d\n", minc);return 0; }

總結(jié)

以上是生活随笔為你收集整理的codeforces738C的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。