Submission #1337436
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int MAXN = 500050; char s[MAXN]; int ans, l, r, n, a[MAXN]; inline bool chk(int x) { int len = n, sum = 0; for( int i = 1 ; i <= n ; i++ ) a[ i ] = ( s[ i ] - '0' ) * 9; a[ 1 ] += 9 * x; for( int i = 1 ; i < len ; i++ ) if( a[ i ] > 9 ) { if( i == len ) a[ ++len ] = 0; a[ i + 1 ] += a[ i ] / 10; a[ i ] %= 10; } for( int i = 1 ; i <= len ; i++ ) sum += a[ i ]; return sum <= 9 * x; } int main() { scanf( "%s", s + 1 ); l = 1, r = n = strlen( s + 1 ); while( l <= r ) { int mid = l + r >> 1; if( chk( mid ) ) ans = mid, r = mid - 1; else l = mid + 1; } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | E - Increasing Numbers |
User | vjudge1 |
Language | Bash (GNU bash v4.3.11) |
Score | 0 |
Code Size | 835 Byte |
Status | RE |
Exec Time | 14 ms |
Memory | 1564 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt, sample4.txt |
All | sample1.txt, sample2.txt, sample3.txt, sample4.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in4.txt, in5.txt, in500000.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | RE | 14 ms | 1564 KB |
in10.txt | RE | 4 ms | 556 KB |
in11.txt | RE | 4 ms | 548 KB |
in12.txt | RE | 4 ms | 556 KB |
in13.txt | RE | 4 ms | 548 KB |
in14.txt | RE | 4 ms | 540 KB |
in15.txt | RE | 4 ms | 556 KB |
in16.txt | RE | 4 ms | 544 KB |
in17.txt | RE | 4 ms | 556 KB |
in18.txt | RE | 4 ms | 540 KB |
in19.txt | RE | 4 ms | 548 KB |
in2.txt | RE | 4 ms | 548 KB |
in20.txt | RE | 4 ms | 544 KB |
in21.txt | RE | 4 ms | 544 KB |
in22.txt | RE | 4 ms | 552 KB |
in23.txt | RE | 4 ms | 544 KB |
in24.txt | RE | 4 ms | 552 KB |
in25.txt | RE | 4 ms | 544 KB |
in26.txt | RE | 4 ms | 548 KB |
in27.txt | RE | 4 ms | 548 KB |
in28.txt | RE | 4 ms | 544 KB |
in29.txt | RE | 4 ms | 552 KB |
in3.txt | RE | 4 ms | 540 KB |
in30.txt | RE | 4 ms | 552 KB |
in31.txt | RE | 4 ms | 544 KB |
in4.txt | RE | 4 ms | 556 KB |
in5.txt | RE | 4 ms | 548 KB |
in500000.txt | RE | 4 ms | 544 KB |
in6.txt | RE | 4 ms | 548 KB |
in7.txt | RE | 4 ms | 544 KB |
in8.txt | RE | 4 ms | 548 KB |
in9.txt | RE | 4 ms | 544 KB |
sample1.txt | RE | 4 ms | 544 KB |
sample2.txt | RE | 4 ms | 540 KB |
sample3.txt | RE | 4 ms | 540 KB |
sample4.txt | RE | 4 ms | 540 KB |