#include <iostream>
#include <vector>
using namespace std;
#define int long long
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int a;
cin >> a;
int cur = 0;
string s = "";
int lposIndex = a-1;
vector<int> curs;
for (size_t i = 0; i < a; i++)
{
curs.push_back(cur);
cur/=10;
int b;
cin >> b;
cur+=b;
//cout << cur << "\n";
}
int tV = 1;
if(cur==0) {
for (size_t i = 0; i < curs.size(); i++)
{
if(curs[i]!=0) {
lposIndex = i-1;
cur = curs[i];
}
}
if(lposIndex==(a-1)) {
cout << 0 << "\n";
return 0;
}
}
for (size_t i = 0; i < 18; i++)
{
tV*=10;
if(tV>=cur) {
cur=cur-(cur%(tV/10));
break;
}
if(i==17 && tV<=cur) {
cur = cur-(cur%1000000000000000000);
}
}
for (size_t i = 0; i < lposIndex; i++)
{
s+='0';
}
cout << cur << s << "\n";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1848 KiB | ||||
2 | Accepted | 3ms | 2052 KiB | ||||
3 | Accepted | 3ms | 2288 KiB | ||||
subtask2 | 25/25 | ||||||
4 | Accepted | 2ms | 2372 KiB | ||||
5 | Accepted | 3ms | 2508 KiB | ||||
6 | Accepted | 3ms | 2556 KiB | ||||
7 | Accepted | 3ms | 2616 KiB | ||||
8 | Accepted | 3ms | 2720 KiB | ||||
subtask3 | 26/26 | ||||||
9 | Accepted | 3ms | 2824 KiB | ||||
10 | Accepted | 3ms | 2852 KiB | ||||
11 | Accepted | 3ms | 2936 KiB | ||||
12 | Accepted | 3ms | 3076 KiB | ||||
13 | Accepted | 2ms | 3156 KiB | ||||
14 | Accepted | 3ms | 3284 KiB | ||||
15 | Accepted | 3ms | 3496 KiB | ||||
16 | Accepted | 3ms | 3704 KiB | ||||
subtask4 | 19/19 | ||||||
17 | Accepted | 3ms | 3812 KiB | ||||
18 | Accepted | 3ms | 3896 KiB | ||||
19 | Accepted | 3ms | 3896 KiB | ||||
20 | Accepted | 3ms | 3816 KiB | ||||
subtask5 | 30/30 | ||||||
21 | Accepted | 24ms | 6068 KiB | ||||
22 | Accepted | 24ms | 5996 KiB | ||||
23 | Accepted | 23ms | 6080 KiB | ||||
24 | Accepted | 24ms | 6060 KiB | ||||
25 | Accepted | 24ms | 5960 KiB | ||||
26 | Accepted | 23ms | 5960 KiB | ||||
27 | Accepted | 16ms | 5972 KiB | ||||
28 | Accepted | 3ms | 4052 KiB |