求助
查看原帖
求助
747009
Spir1t楼主2023/11/6 20:02

求助,RE

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using db=double;
using ull = unsigned long long;
const ll INF=9223372036854775807;
const int inf=2147483647;
inline ll pw(ll a,ll b,ll p=INF){if(b==0)return 1;if(b==1)return a%p;ll mid=pw(a,b/2,p)%p;if(b&1)return mid*mid%p*a%p;else{return mid*mid%p;}}
pair<int, int> f(int n, const vector<int>& times) {
	int a_time = 0;
	int b_time = 0;
	int a_pos = 1;
	int b_pos = n;
	while(a_pos<=b_pos) {
		if(a_time<=b_time) a_time+=times[a_pos++];
		else b_time+=times[b_pos--];
	}
	return make_pair(a_pos-1, n-b_pos);
}
signed main() {
	//	freopen("123.in","r",stdin);
	//	freopen("123.out","w,",stdout);
	int n;
	cin >> n;
	vector<int> times(n);
	for (int i = 1; i <= n; i++) {
		cin >> times[i];
	}
	pair<int, int> ans = f(n, times);
	cout << ans.first << " " << ans.second << endl;
	//	fclose(stdin);
	//	fclose(stdout);
	return 0;
}




2023/11/6 20:02
加载中...