234C. Weather
生活随笔
收集整理的這篇文章主要介紹了
234C. Weather
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
C. Weather:題目
為什么直接交代碼不行啊,非要加兩句話,有沒有大佬說(shuō)說(shuō)? #include <bits/stdc++.h> using namespace std; // typedef long long ll; vector<int> a((int)3e5); vector<int> b((int)3e5), c((int)3e5); int main() {freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);int n;cin >> n;if (n==2) {int cou = 0,x;cin>>x;if (x>=0) cou++;cin>>x;if (x<=0) cou++;cout<<cou<<endl;return 0;}b[0] = c[n + 1] = 0;for (int i = 1; i <= n; i++){cin >> a[i];}for (int i = 1; i <= n; i++){b[i] = b[i - 1];if (a[i] >= 0)b[i]++;}for (int i = n; i >= 1; i--){c[i] = c[i + 1];if (a[i] <= 0)c[i]++;}int res = (int)2e5;for (int i = 2; i <= n-1; i++){if (a[i] != 0)res = min(res, b[i - 1] + c[i + 1]);elseres = min(res, b[i - 1] + c[i + 1] + 1);}cout << res << endl; } 2022年2月27日,1:38,還有一題1300結(jié)束總結(jié)
以上是生活随笔為你收集整理的234C. Weather的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 使用mockjs模拟数据
- 下一篇: WebRAY权小文:产品就是工程师的尊严