#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool palindrome (string & s) {
int l = 0, r = (int)s.size() - 1;
while (l <= r) {
if (s[l] != s[r]) return false;
l++; r--;
}
return true;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
ll n, x, sum = 0;
vector<ll> vi;
vector<string> vs;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
vi.push_back(x);
vs.push_back(to_string(x));
}
for (int i = 0; i < n; i++) {
if (palindrome(vs[i])) sum += vi[i];
}
cout << sum << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
1228 KB |
Output is correct |
3 |
Correct |
101 ms |
28800 KB |
Output is correct |
4 |
Correct |
156 ms |
50764 KB |
Output is correct |
5 |
Correct |
242 ms |
57312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
1060 KB |
Output is correct |
3 |
Correct |
69 ms |
23964 KB |
Output is correct |
4 |
Correct |
131 ms |
47628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
1060 KB |
Output is correct |
3 |
Correct |
69 ms |
23964 KB |
Output is correct |
4 |
Correct |
131 ms |
47628 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
6 ms |
1736 KB |
Output is correct |
7 |
Correct |
121 ms |
45428 KB |
Output is correct |
8 |
Correct |
151 ms |
47644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
1228 KB |
Output is correct |
3 |
Correct |
101 ms |
28800 KB |
Output is correct |
4 |
Correct |
156 ms |
50764 KB |
Output is correct |
5 |
Correct |
242 ms |
57312 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
1060 KB |
Output is correct |
8 |
Correct |
69 ms |
23964 KB |
Output is correct |
9 |
Correct |
131 ms |
47628 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
6 ms |
1736 KB |
Output is correct |
12 |
Correct |
121 ms |
45428 KB |
Output is correct |
13 |
Correct |
151 ms |
47644 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
7 ms |
1992 KB |
Output is correct |
16 |
Correct |
85 ms |
25536 KB |
Output is correct |
17 |
Correct |
223 ms |
52416 KB |
Output is correct |
18 |
Correct |
197 ms |
57296 KB |
Output is correct |
19 |
Correct |
199 ms |
57212 KB |
Output is correct |
20 |
Correct |
198 ms |
57348 KB |
Output is correct |