Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
98336 CSYZYeShuChen 早凉的函数2 C++ 运行超时 20 1000 MS 3376 KB 790 2023-08-14 15:21:43

Tests(13/17):


#include<bits/stdc++.h> #define int long long using namespace std; int n, mod, ans, sum; int a[200005], b[200005]; inline bool cmp(int x, int y) {return x % mod < y % mod;} signed main() { cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) { int tmp = a[i]; while(tmp) { ans += tmp % 10; tmp /= 10; } } ans = 2 * n * ans; for(mod = 10; mod <= 1e15; mod *= 10) { sort(a + 1, a + n + 1, cmp); for(int i = 1; i <= n; i++) b[i] = a[i] % mod; for(int i = 1; i <= n; i++) { int l = 1, r = n, pos = n + 1; while(l <= r) { int mid = l + r >> 1; if(b[mid] < mod - b[i]) l = mid + 1; else r = (pos = mid) - 1; } sum += (n - pos + 1); } } cout << ans - sum * 9; return 0; }


测评信息: