QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#788380#5149. Best Carry PlayerTauLee01WA 13ms34956kbC++232.6kb2024-11-27 16:43:552024-11-27 16:43:56

Judging History

你现在查看的是最新测评结果

  • [2024-11-27 16:43:56]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:34956kb
  • [2024-11-27 16:43:55]
  • 提交

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[20];
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, 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 34956kb

input:

2
3
9 99 999
1
12345

output:

5
0

result:

ok 2 number(s): "5 0"

Test #2:

score: 0
Accepted
time: 10ms
memory: 34884kb

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: -100
Wrong Answer
time: 13ms
memory: 34892kb

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
42
42
35
44
36
44
38
40
46
32
40
42
39
38
42
39
39
38
42
39
41
39
42
42
39
40
46
36
43
37
41
41
42
40
36
50
40
42
34
44
44
46
42
35
43
40
41
40
38
34
45
39
44
38
41
41
36
36
45
38
39
41
41
44
45
42
43
41
42
39
41
39
43
41
41
42
43
41
40
38
41
37
42
42
40
45
35
37
44
40
37
36
44
41
42
44
44
32
39
...

result:

wrong answer 2nd numbers differ - expected: '41', found: '42'