QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103324#5149. Best Carry PlayerSnowNorthWA 46ms3460kbC++14785b2023-05-05 10:55:552023-05-05 10:55:59

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-05 10:55:59]
  • 评测
  • 测评结果:WA
  • 用时:46ms
  • 内存:3460kb
  • [2023-05-05 10:55:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10; 

int v[N];

int get (int x, int y) {
	if (x < y) swap (x, y);
	
	vector<int> a, b;
	while (x || y) {
		a.push_back (x % 10);
		b.push_back (y % 10);
		x /= 10;
		y /= 10;
	}
	
	int res(0);
	for (int i = 0; i < a.size(); i++) {
		if (a[i] + b[i] >= 10) {
			if (i + 1 < a.size()) a[i + 1] ++;
			res ++;
		}
	}
	return res;
}

void solve() {
	int n;
	cin >> n;
	
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	
	int ans(0), sum(0);
	for (int i = 1; i <= n; i++) {
		ans += get (sum, v[i]);
		sum += v[i];
	}
	
	cout << ans << "\n";
}

signed main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int T;
	cin >> T;
	while (T--)
	solve();
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3
9 99 999
1
12345

output:

5
0

result:

ok 2 number(s): "5 0"

Test #2:

score: 0
Accepted
time: 46ms
memory: 3400kb

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: 36ms
memory: 3460kb

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:

20
23
26
18
21
17
25
24
23
33
9
25
19
18
25
22
24
27
17
23
18
20
18
19
18
24
17
33
21
26
19
18
28
22
20
20
33
28
33
22
29
25
24
25
32
30
15
21
17
16
18
33
21
20
25
20
18
28
21
27
13
23
17
25
24
31
27
22
21
32
21
15
21
29
22
22
25
29
19
15
18
24
19
27
25
13
27
20
15
29
16
23
24
25
27
22
27
31
16
21
1...

result:

wrong answer 1st numbers differ - expected: '42', found: '20'