intmain() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int a = 1; int M, sum = 0; cin >> M; vector<int> D(M); for(int i = 0; i < M; i++) cin >> D[i], sum += D[i]; sum = (sum + 1) / 2; for(int i = 0; i < M; i++) { if(sum > D[i]) { sum -= D[i]; a++; } elsebreak; } cout << a << ' ' << sum;
namespace solve { intread() { int x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; }
voidsolve() { int n = read(); std::vector<std::vector<int>> g(n, std::vector<int>()); for(int i = 0; i < n; i++) { int x = read(); for(int j = 0; j < x; j++) { int v = read(); v--; g[i].emplace_back(v); } }
auto tosport = [&]() -> std::vector<int> { std::vector<int> d(n); for(int i = 0; i < n; i++) for(auto x : g[i]) d[x]++; std::vector<int> res; std::queue<int> que; for (int i = 0; i < n; i++) if (d[i] == 0) que.push(i); while(que.size()) { auto t = que.front(); que.pop(); res.push_back(t); for(int x : g[t]) { d[x]--; if(d[x] == 0) que.push(x); } } return res; };
std::queue<int> q; q.push(0); std::vector<bool> f(n + 1); while(q.size()) { auto t = q.front(); q.pop(); for (int i : g[t]) { if (!f[i]) { f[i] = true; q.push(i); } } } std::vector<int> t = tosport(); std::vector<int> order(n); for(int i = 0; i < n; i++) order[t[i]] = i; std::sort(t.begin(), t.end(), [&](int x, int y) -> bool { return order[x] > order[y]; }); for(auto x : t) if(f[x]) std::cout << x + 1 << " "; }