Submission #1064189


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

struct po{
  ll m,mx;
  po* ko[10];
};

po pool[1000005];
int poolcnt;

po* make_node(){
  po* res=&pool[poolcnt++];
  res->m=res->mx=0;
  for(int i=0;i<10;i++)res->ko[i]=NULL;
  return res;
}

ll dfs(int a,int b,po* p){
  if(!a){p->m+=b;return p->mx+=b;}
  if(p->ko[a%10]==NULL)p->ko[a%10]=make_node();
  ll s=dfs(a/10,b,p->ko[a%10])+p->m;
  p->mx=max(s,p->mx);
  return s;
}

int main(){
  int n;
  cin>>n;
  int a,b;
  po *o=make_node();
  for(int i=0;i<n;i++){
    cin>>a>>b;
    dfs(a,b,o);
    cout<<o->mx<<endl;
  }
  return 0;
}

Submission Info

Submission Time
Task E - 宝くじ
User kawabys
Language C++ (GCC 4.9.2)
Score 200
Code Size 642 Byte
Status AC
Exec Time 599 ms
Memory 48624 KB

Judge Result

Set Name All
Score / Max Score 200 / 200
Status
AC × 25
Set Name Test Cases
All scrambled_00.txt, scrambled_01.txt, scrambled_02.txt, scrambled_03.txt, scrambled_04.txt, scrambled_05.txt, scrambled_06.txt, scrambled_07.txt, scrambled_08.txt, scrambled_09.txt, scrambled_10.txt, scrambled_11.txt, scrambled_12.txt, scrambled_13.txt, scrambled_14.txt, scrambled_15.txt, scrambled_16.txt, scrambled_17.txt, scrambled_18.txt, scrambled_19.txt, scrambled_20.txt, scrambled_21.txt, scrambled_22.txt, scrambled_23.txt, scrambled_24.txt
Case Name Status Exec Time Memory
scrambled_00.txt AC 18 ms 796 KB
scrambled_01.txt AC 17 ms 672 KB
scrambled_02.txt AC 490 ms 800 KB
scrambled_03.txt AC 407 ms 800 KB
scrambled_04.txt AC 469 ms 800 KB
scrambled_05.txt AC 331 ms 800 KB
scrambled_06.txt AC 384 ms 916 KB
scrambled_07.txt AC 130 ms 924 KB
scrambled_08.txt AC 211 ms 792 KB
scrambled_09.txt AC 430 ms 924 KB
scrambled_10.txt AC 365 ms 800 KB
scrambled_11.txt AC 125 ms 796 KB
scrambled_12.txt AC 358 ms 924 KB
scrambled_13.txt AC 101 ms 800 KB
scrambled_14.txt AC 480 ms 20316 KB
scrambled_15.txt AC 38 ms 1780 KB
scrambled_16.txt AC 481 ms 19692 KB
scrambled_17.txt AC 85 ms 4120 KB
scrambled_18.txt AC 452 ms 18848 KB
scrambled_19.txt AC 599 ms 48624 KB
scrambled_20.txt AC 586 ms 43508 KB
scrambled_21.txt AC 379 ms 28828 KB
scrambled_22.txt AC 372 ms 28652 KB
scrambled_23.txt AC 96 ms 7332 KB
scrambled_24.txt AC 173 ms 13996 KB