QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#691830 | #6702. Stones in the Bucket | Kdlyh# | AC ✓ | 57ms | 4356kb | C++20 | 2.0kb | 2024-10-31 13:09:29 | 2024-10-31 13:09:30 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <stack>
#ifdef LOCAL
template <class T, size_t size = std::tuple_size<T>::value> std::string to_debug(T, std::string s = "") requires(not std::ranges::range<T>);
std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); }
std::string to_debug(std::ranges::range auto x, std::string s = "") requires(not std::is_same_v<decltype(x), std::string>) {
for (auto xi : x) { s += ", " + to_debug(xi); }
return "[" + s.substr(s.empty() ? 0 : 2) + "]";
}
template <class T, size_t size> std::string to_debug(T x, std::string s) requires(not std::ranges::range<T>) {
[&]<size_t... I>(std::index_sequence<I...>) { ((s += ", " + to_debug(get<I>(x))), ...); }(std::make_index_sequence<size>());
return "(" + s.substr(s.empty() ? 0 : 2) + ")";
}
#define debug(...) std::cerr << __LINE__ << ": (" #__VA_ARGS__ ") = " << to_debug(std::tuple(__VA_ARGS__)) << "\n"
#else
#define debug(x...)
#endif
using i64 = long long;
#define int long long
void solve()
{
#define tests
int n;
std::cin >> n;
std::vector <int> a(n + 10);
int sum{};
for(int i = 0 ; i < n ; i++){
std::cin >> a[i];
sum += a[i];
}
int d{sum / n};
int ans{};
for(int i = 0 ; i < n ; i++){
if(a[i] > d){
ans += a[i] - d;
}
}
std::cout << ans <<"\n";
}
signed main()
{
std::cin.tie(nullptr)->sync_with_stdio(false);
int _{1};
#ifdef tests
std::cin >> _;
#endif
while(_--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
input:
4 3 1 1 0 4 2 2 2 2 3 0 1 4 1 1000000000
output:
2 0 3 0
result:
ok 4 number(s): "2 0 3 0"
Test #2:
score: 0
Accepted
time: 57ms
memory: 4356kb
input:
1117 33 941569937 726092914 727010359 7765372 85147698 226034704 430957397 690012188 507130442 797501882 635162155 159230168 519209938 874599298 394229092 840562882 790604785 404365317 201055932 846306030 538284769 767560597 989100484 910102919 156114543 743142429 790221319 144002373 730823403 97104...
output:
4211193781 3489319388 4015689082 4369484417 12451656301 3389745192 9279595149 7756415264 8458888261 9562054408 8819462646 8776257522 3213169624 849909175 9911233579 224339683 8383256653 4953209012 7534373352 9297501816 1839870320 3914938851 8950069661 7010274970 9453850869 8777334685 3992301260 8296...
result:
ok 1117 numbers