Submission #1064180


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 OKA
Language C++ (GCC 4.9.2)
Score 200
Code Size 657 Byte
Status AC
Exec Time 602 ms
Memory 48684 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 924 KB
scrambled_01.txt AC 17 ms 924 KB
scrambled_02.txt AC 482 ms 920 KB
scrambled_03.txt AC 430 ms 800 KB
scrambled_04.txt AC 485 ms 796 KB
scrambled_05.txt AC 317 ms 928 KB
scrambled_06.txt AC 380 ms 796 KB
scrambled_07.txt AC 135 ms 928 KB
scrambled_08.txt AC 207 ms 924 KB
scrambled_09.txt AC 436 ms 800 KB
scrambled_10.txt AC 368 ms 796 KB
scrambled_11.txt AC 132 ms 920 KB
scrambled_12.txt AC 354 ms 916 KB
scrambled_13.txt AC 103 ms 924 KB
scrambled_14.txt AC 498 ms 20260 KB
scrambled_15.txt AC 41 ms 1780 KB
scrambled_16.txt AC 479 ms 19732 KB
scrambled_17.txt AC 91 ms 4136 KB
scrambled_18.txt AC 451 ms 18844 KB
scrambled_19.txt AC 602 ms 48684 KB
scrambled_20.txt AC 598 ms 43528 KB
scrambled_21.txt AC 385 ms 28828 KB
scrambled_22.txt AC 383 ms 28584 KB
scrambled_23.txt AC 98 ms 7404 KB
scrambled_24.txt AC 184 ms 13976 KB