QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#788391 | #5149. Best Carry Player | TauLee01 | WA | 19ms | 34976kb | C++23 | 2.6kb | 2024-11-27 16:45:55 | 2024-11-27 16:46:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ull unsigned long long
#define ms(x, y) memset(x, y, sizeof x);
#define debug(x) cout << #x << " = " << x << endl;
#define ios ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define fre \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
const int mod = 998244353;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 10;
const double esp = 1e-6;
const ull MOD1 = 1610612741;
const ull MOD2 = 805306457;
const ull BASE1 = 1331;
const ull BASE2 = 131;
#define pre(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
char *p1, *p2, buf[100000]; // 快读和同步流二者只能选一个
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++)
int read()
{
int x = 0, f = 1;
char ch = nc();
while (ch < 48 || ch > 57)
{
if (ch == '-')
f = -1;
ch = nc();
}
while (ch >= 48 && ch <= 57)
x = x * 10 + ch - 48, ch = nc();
return x * f;
}
void write(int x)
{
if (x < 0)
putchar('-'), x = -x;
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
return;
}
int n;
string s[N];
int p[100];
int ans;
void fun(string s)
{
reverse(s.begin(), s.end());
int tp = 0;
for (int i = 0; i < s.size(); i++)
{
tp = (p[i] + s[i] - '0') / 10;
p[i] = (p[i] + s[i] - '0') % 10;
if (tp)
{
ans++;
p[i + 1] += tp;
}
}
int m = s.size();
if (p[m] >= 10)
{
p[m] %= 10;
p[m + 1]++;
ans++;
}
return;
}
void solve()
{
cin >> n;
ans = 0;
pre(i, 0, 99) p[i] = 0;
pre(i, 1, n) cin >> s[i];
reverse(s[1].begin(), s[1].end());
for (int i = 0; i < s[1].size(); i++)
p[i] = s[1][i] - '0';
pre(i, 2, n)
{
fun(s[i]);
}
cout << ans << endl;
}
// #define LOCAL
signed main()
{
ios
// fre
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
auto start = std::chrono::high_resolution_clock::now();
#endif
int t = 1;
cin >> t;
while (t--)
solve();
#ifdef LOCAL
auto end = std::chrono::high_resolution_clock::now();
cout << "Execution time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
<< " ms" << '\n';
#endif
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 34848kb
input:
2 3 9 99 999 1 12345
output:
5 0
result:
ok 2 number(s): "5 0"
Test #2:
score: 0
Accepted
time: 19ms
memory: 34860kb
input:
100000 1 481199252 1 634074578 1 740396295 1 579721198 1 503722503 1 202647942 1 268792718 1 443917727 1 125908043 1 717268783 1 150414369 1 519096230 1 856168102 1 674936674 1 274667941 1 527268921 1 421436316 1 286802932 1 646837311 1 451394766 1 105650419 1 302790137 1 254786900 1 76141081 1 7393...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 numbers
Test #3:
score: 0
Accepted
time: 17ms
memory: 34976kb
input:
10000 10 598196518 640274071 983359971 71550121 96204862 799843967 446173607 796619138 402690754 223219513 10 312183499 905549873 673542337 566661387 879397647 434495917 631413076 150918417 579868000 224422012 10 525305826 535526356 404334728 653535984 998133227 879226371 59632864 356493387 62611196...
output:
42 41 42 35 43 35 44 38 39 46 31 40 42 38 38 41 39 39 37 42 38 41 38 42 41 39 40 45 35 41 37 40 41 41 40 35 50 39 42 33 44 43 46 41 35 42 39 41 39 38 34 44 39 43 38 40 41 36 35 45 37 39 40 41 43 44 41 43 40 42 37 41 38 43 40 40 42 42 41 40 37 41 36 42 41 40 44 35 37 43 40 36 36 43 41 41 43 44 32 38 ...
result:
ok 10000 numbers
Test #4:
score: 0
Accepted
time: 15ms
memory: 34848kb
input:
1000 95 708441014 953465932 817091665 611120528 186861396 45214633 309108293 362222948 134971428 346366757 945798520 132315932 293683620 945425590 668726142 893155157 191896353 57521218 112217858 641511394 672365121 156197927 495345729 585777737 567289722 592583094 842472845 908714567 355422360 5153...
output:
421 415 405 417 423 430 439 455 442 423 412 435 435 414 427 426 449 415 421 419 438 436 444 419 417 414 408 412 432 413 420 418 437 433 435 411 428 446 437 412 448 413 435 411 445 441 456 416 395 446 415 405 430 397 448 434 424 401 450 424 402 443 437 411 403 398 426 415 429 435 428 427 426 445 425 ...
result:
ok 1000 numbers
Test #5:
score: -100
Wrong Answer
time: 12ms
memory: 34852kb
input:
100 994 12244197 302751325 391063232 821704902 918351183 911667041 414131481 556158495 532207266 811890152 401118704 474105790 920464458 363136546 386056258 201743030 836389366 341427747 904710546 10486332 810273816 162407523 690627683 544009771 458562152 915779647 609419967 988646785 282973793 7557...
output:
4421 4256 4288 4084 4476 4435 4373 4073 4101 4226 4057 4380 4288 4255 4478 4364 4291 4310 4177 4020 4269 4011 4191 4094 4379 4049 4222 4190 4345 4374 4463 4248 4131 4284 4134 4252 4066 4203 4063 4476 4408 4304 4132 4438 4489 4101 4242 4447 4217 4096 4447 4397 4325 4255 4122 4118 4420 4537 4313 4373 ...
result:
wrong answer 1st numbers differ - expected: '4425', found: '4421'