Submission #100357

# Submission time Handle Problem Language Result Execution time Memory
100357 2019-03-10T14:04:21 Z Ort Lun (COCI19_lun) C++11
40 / 50
3 ms 384 KB
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cctype>

using namespace std;

string s;
vector<int> sv;
int n; bool t;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n;
	cin >> s;
	reverse(s.begin(),s.end());
	for(int i=0;i<n;i++) {
		if(isdigit(s[i])) {
			if(i%2) {
				int num = s[i]-'0';
				num *= 2;
				if(num>9) num = (num%10) + (num/10);
				sv.push_back(num);	
			}
			else sv.push_back(s[i]-'0');
		}
		else {sv.push_back(-1); if(i%2) t=1;}
	}
	long long sum = 0;
	for(int i=0;i<n;i++) sum += (long long)(sv[i]!=-1?sv[i]:0);
	if(!t) cout << (sum*9)%10;
	else cout << ((sum*9)%10) /2;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Incorrect 3 ms 300 KB Output isn't correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Correct 2 ms 384 KB Output is correct