#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll MAXN=1e6+10;
const ll MAXA=1e9+10;
ll n;
string a[MAXN];
ll string_to_int(string s)
{
ll res=0;
ll sz=s.size();
for(ll i=sz-1;i>=0;i--)
{
res*=10;
res+=(s[i]-'0');
}
return res;
}
bool isPalindrome(string s)
{
string revs=s;
reverse(revs.begin(), revs.end());
return s == revs;
}
void read()
{
cin>>n;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
}
}
void solve()
{
ll ans=0;
for(ll i=1;i<=n;i++)
{
string s=a[i];
if(isPalindrome(s))
{
ll cur=string_to_int(s);
ans+=cur;
}
}
cout<<ans<<endl;
}
int main()
{
#ifdef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
read();
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
31580 KB |
Output is correct |
2 |
Correct |
8 ms |
31836 KB |
Output is correct |
3 |
Correct |
53 ms |
36348 KB |
Output is correct |
4 |
Correct |
75 ms |
38744 KB |
Output is correct |
5 |
Correct |
98 ms |
41296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
31580 KB |
Output is correct |
2 |
Correct |
9 ms |
31576 KB |
Output is correct |
3 |
Correct |
44 ms |
33160 KB |
Output is correct |
4 |
Correct |
75 ms |
34656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
31580 KB |
Output is correct |
2 |
Correct |
9 ms |
31576 KB |
Output is correct |
3 |
Correct |
44 ms |
33160 KB |
Output is correct |
4 |
Correct |
75 ms |
34656 KB |
Output is correct |
5 |
Correct |
7 ms |
31580 KB |
Output is correct |
6 |
Correct |
8 ms |
31832 KB |
Output is correct |
7 |
Correct |
69 ms |
34800 KB |
Output is correct |
8 |
Correct |
87 ms |
35412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
31580 KB |
Output is correct |
2 |
Correct |
8 ms |
31836 KB |
Output is correct |
3 |
Correct |
53 ms |
36348 KB |
Output is correct |
4 |
Correct |
75 ms |
38744 KB |
Output is correct |
5 |
Correct |
98 ms |
41296 KB |
Output is correct |
6 |
Correct |
7 ms |
31580 KB |
Output is correct |
7 |
Correct |
9 ms |
31576 KB |
Output is correct |
8 |
Correct |
44 ms |
33160 KB |
Output is correct |
9 |
Correct |
75 ms |
34656 KB |
Output is correct |
10 |
Correct |
7 ms |
31580 KB |
Output is correct |
11 |
Correct |
8 ms |
31832 KB |
Output is correct |
12 |
Correct |
69 ms |
34800 KB |
Output is correct |
13 |
Correct |
87 ms |
35412 KB |
Output is correct |
14 |
Correct |
7 ms |
31580 KB |
Output is correct |
15 |
Correct |
10 ms |
31880 KB |
Output is correct |
16 |
Correct |
43 ms |
35472 KB |
Output is correct |
17 |
Correct |
87 ms |
40192 KB |
Output is correct |
18 |
Correct |
118 ms |
41216 KB |
Output is correct |
19 |
Correct |
94 ms |
41412 KB |
Output is correct |
20 |
Correct |
95 ms |
41300 KB |
Output is correct |