Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
91180 sh25_shenpy 龙虎斗 C++ 解答错误 9 MS 1036 KB 1477 2026-06-12 15:13:49

Tests(1/25):


#include <bits/stdc++.h> inline long long read () { register long long x = 0 , ch = getchar(); while( !isdigit(ch)) ch = getchar(); while( isdigit(ch) ) x = x * 10 + ch - '0' , ch = getchar(); return x; } inline long long abs (long long x) { if(x >= 0) return x; return -x; } long long m, p1, s1, s2, a[1000005], t1, t2; int n; int main () { double where; long long gap; n = read(); for(int i = 1; i <= n; i ++ ) { a[i] = read(); } m = read(); p1 = read(); s1 = read(); s2 = read();//这些都是快读,不用管 a[p1] += s1; for(int i = 1; i <= n; i ++ ) { gap += (m - i) * a[i]; } double dgap = gap; long long int ans; where = m + dgap / s2;//方程的解 if(where >= n) {//大于等于n的情况 ans = n; } else if(where <= 1)//小于等于1的情况 ans = 1; else { int iwhere = where;//判断是不是整数 if(iwhere == where) ans = iwhere;//如果是整数 else { long long ans1 = abs(gap + (m - iwhere ) * s2); long long ans2 = abs(gap + (m - iwhere - 1) * s2);//分别计算把s2个工兵放在向下取整和向上取整两个兵营里之后的势力之差 ans = ans1 <= ans2 ? iwhere : iwhere + 1;//三目运算符 } } printf("%lld", ans);//答案输出 return 0; }


测评信息: