Submission #00036
ソースコード
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 | #include<bits/stdc++.h> using namespace std; typedef long long int64; struct node { int64 value, sum; map< int , struct node* > child; node() { value = 0, sum = 0; }; }; node pool[11451419]; int head; void tree( const string& a, int idx, int add, node* n) { if (idx == -1) { n -> value += add; n -> sum += add; return ; } if (n -> child.find(a[idx]) == n -> child.end()) { n -> child[a[idx]] = &pool[head++]; } tree(a, idx - 1, add, n -> child[a[idx]]); n -> sum = max(n -> sum, n -> value + n -> child[a[idx]] -> sum); } int main() { int n; cin >> n; head = 1; for ( int i = 0; i < n; i++) { string a; int b; cin >> a >> b; tree(a, a.size() - 1, b, &pool[0]); cout << pool[0].sum << endl; } } |
ステータス
項目 | データ |
---|---|
問題 | 0008 - 宝くじ |
ユーザー名 | I dont any |
投稿日時 | 2015-08-28 09:37:41 |
言語 | C++11 |
状態 | Memory Limit Exceeded |
得点 | 0 |
ソースコード長 | 805 Byte |
最大実行時間 | 5000 ms |
最大メモリ使用量 | 262144 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 30 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
scrambled_00.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_01.txt | MLE | 5000 ms | 262144 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 | MLE | 5000 ms | 262144 KB |
1
|
scrambled_10.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_11.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_12.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_13.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_14.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_15.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_16.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_17.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_18.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_19.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_20.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_21.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_22.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_23.txt | MLE | 5000 ms | 262144 KB |
1
|
scrambled_24.txt | MLE | 5000 ms | 262144 KB |
1
|