Submission #00160


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;
const int MAX_N = 100010;
typedef long long ll;
typedef pair<string, ll> P;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<P> vec;
for(int i = 0; i < n; ++i){
ll a, b;
cin >> a >> b;
string str = to_string(a);
ll m = 0;
size_t vecs = vec.size();
bool check2 = false;
for(size_t j = 0; j < vecs; ++j){
m = max(m, vec[j].second);
size_t vecjs = vec[j].first.size();
bool check = true;
for(size_t k = 0; k < min(str.size(), vecjs); ++k){
if(str[str.size() - (1 + k)] != vec[j].first[vecjs - (1 + k)]){
check = false;
break;
}
}
//cout << cnt << endl;
if(check){
if(str.size() >= vecjs){
vec.push_back(P(str, b + vec[j].second));
check2 = true;
}
else {
vec.push_back(P(vec[j].first, b + vec[j].second));
vec.erase(vec.begin() + j);
}
m = max(m, b + vec[j].second);
}
}
if(!check2) vec.push_back(P(str, b));
m = max(m, b);
cout << m << endl;
}
return 0;
}

ステータス

項目 データ
問題 0008 - 宝くじ
ユーザー名 mds_boy
投稿日時 2015-08-28 11:31:32
言語 C++11
状態 Wrong Answer
得点 0
ソースコード長 1497 Byte
最大実行時間 5000 ms
最大メモリ使用量 262144 KB

セット

セット 得点 Cases
1 ALL 0 / 30 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
scrambled_00.txt WA 24 ms 476 KB
1
scrambled_01.txt AC 19 ms 444 KB
1
scrambled_02.txt MLE 5000 ms 262144 KB
1
scrambled_03.txt MLE 5000 ms 262144 KB
1
scrambled_04.txt MLE 5000 ms 262144 KB
1
scrambled_05.txt MLE 5000 ms 262144 KB
1
scrambled_06.txt MLE 5000 ms 262144 KB
1
scrambled_07.txt MLE 5000 ms 262144 KB
1
scrambled_08.txt MLE 5000 ms 262144 KB
1
scrambled_09.txt TLE 5000 ms 3200 KB
1
scrambled_10.txt TLE 5000 ms 3380 KB
1
scrambled_11.txt TLE 5000 ms 3312 KB
1
scrambled_12.txt TLE 5000 ms 3268 KB
1
scrambled_13.txt TLE 5000 ms 3164 KB
1
scrambled_14.txt TLE 5000 ms 11272 KB
1
scrambled_15.txt TLE 5000 ms 12752 KB
1
scrambled_16.txt TLE 5000 ms 11964 KB
1
scrambled_17.txt TLE 5000 ms 7776 KB
1
scrambled_18.txt TLE 5000 ms 6988 KB
1
scrambled_19.txt TLE 5000 ms 7360 KB
1
scrambled_20.txt TLE 5000 ms 4412 KB
1
scrambled_21.txt TLE 5000 ms 4972 KB
1
scrambled_22.txt TLE 5000 ms 5528 KB
1
scrambled_23.txt AC 281 ms 4104 KB
1
scrambled_24.txt WA 1165 ms 4880 KB
1