Submission #1064182


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();
  o->mx=-1;
  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 655 Byte
Status AC
Exec Time 600 ms
Memory 48588 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 19 ms 800 KB
scrambled_01.txt AC 18 ms 796 KB
scrambled_02.txt AC 479 ms 924 KB
scrambled_03.txt AC 421 ms 928 KB
scrambled_04.txt AC 508 ms 796 KB
scrambled_05.txt AC 307 ms 800 KB
scrambled_06.txt AC 372 ms 796 KB
scrambled_07.txt AC 132 ms 800 KB
scrambled_08.txt AC 205 ms 924 KB
scrambled_09.txt AC 430 ms 796 KB
scrambled_10.txt AC 370 ms 800 KB
scrambled_11.txt AC 129 ms 800 KB
scrambled_12.txt AC 346 ms 928 KB
scrambled_13.txt AC 94 ms 796 KB
scrambled_14.txt AC 494 ms 20264 KB
scrambled_15.txt AC 34 ms 1820 KB
scrambled_16.txt AC 476 ms 19740 KB
scrambled_17.txt AC 91 ms 4072 KB
scrambled_18.txt AC 451 ms 18876 KB
scrambled_19.txt AC 600 ms 48588 KB
scrambled_20.txt AC 587 ms 43424 KB
scrambled_21.txt AC 378 ms 28796 KB
scrambled_22.txt AC 370 ms 28580 KB
scrambled_23.txt AC 94 ms 7412 KB
scrambled_24.txt AC 181 ms 14088 KB