51 lines
888 B
C++
51 lines
888 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
|
|
int main(){
|
|
ios::sync_with_stdio(0);
|
|
cin.tie(0);
|
|
|
|
int n;
|
|
cin >> n;
|
|
|
|
vector<map<int, int>> reels(n);
|
|
|
|
for(int i = 0; i < n; ++i){
|
|
long long reel_in;
|
|
cin >> reel_in;
|
|
|
|
for(int j = 9; j >= 0; --j){
|
|
int l = reel_in % 10;
|
|
reel_in /= 10;
|
|
|
|
reels[i][l] = j;
|
|
}
|
|
}
|
|
|
|
set<int> button_presses;
|
|
int min_time = 100000;
|
|
|
|
for(int i = 0; i < 10; ++i){
|
|
button_presses.clear();
|
|
|
|
for(int j = 0; j < n; ++j){
|
|
int time = reels[i][j];
|
|
while(button_presses.count(time)){
|
|
time += 10;
|
|
}
|
|
button_presses.insert(time);
|
|
|
|
if(time < min_time){
|
|
min_time = time;
|
|
}
|
|
}
|
|
}
|
|
|
|
cout << min_time << endl;
|
|
|
|
cout << flush;
|
|
|
|
return 0;
|
|
} |