Submission #8580845


Source Code Expand

Copy
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    ll m, d[200020], c[200020];
    cin >> m;
    for (int i = 0; i < m; i++) cin >> d[i] >> c[i];

    ll ans = 0, bef = -1;
    vector<int> sp;
    for (int i = 0; i < m; i++) {
        while (c[i] != 0) {
            if (c[i] % 2) sp.push_back(d[i]);
            if (d[i] >= 5) ans += (c[i] / 2) * 2;
            else ans += (c[i] / 2) * 2 / 2;
            d[i] = (d[i] * 2) % 10 + (d[i] >= 5);
            c[i] /= 2;
        }
    }
  	//cout << ans << endl;
    bef = 0;
    for (int i = 0; i < sp.size(); i++) {
        bef += sp[i];
        if (i != 0) ans++;
        if (bef >= 10) {
            bef = bef % 10 + 1;
            ans++;
        }
    }
    cout << ans << endl;

}

Submission Info

Submission Time
Task D - Digit Sum Replace
User ast210
Language C++14 (GCC 5.4.1)
Score 500
Code Size 945 Byte
Status AC
Exec Time 185 ms
Memory 21224 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 20
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt
All 00-sample-01.txt, 00-sample-02.txt, 01-corner-01.txt, 01-corner-02.txt, 01-corner-03.txt, 02-random-01.txt, 02-random-02.txt, 02-random-03.txt, 02-random-04.txt, 02-random-05.txt, 02-random-06.txt, 02-random-07.txt, 02-random-08.txt, 02-random-09.txt, 02-random-10.txt, 02-random-11.txt, 03-max-01.txt, 03-max-02.txt, 04-min-01.txt, 04-min-02.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 2 ms 2304 KB
00-sample-02.txt AC 1 ms 256 KB
01-corner-01.txt AC 1 ms 256 KB
01-corner-02.txt AC 2 ms 2304 KB
01-corner-03.txt AC 1 ms 256 KB
02-random-01.txt AC 2 ms 2304 KB
02-random-02.txt AC 2 ms 2304 KB
02-random-03.txt AC 1 ms 256 KB
02-random-04.txt AC 1 ms 256 KB
02-random-05.txt AC 1 ms 256 KB
02-random-06.txt AC 171 ms 20072 KB
02-random-07.txt AC 176 ms 19944 KB
02-random-08.txt AC 180 ms 20840 KB
02-random-09.txt AC 175 ms 20840 KB
02-random-10.txt AC 183 ms 20712 KB
02-random-11.txt AC 185 ms 20840 KB
03-max-01.txt AC 134 ms 20712 KB
03-max-02.txt AC 1 ms 256 KB
04-min-01.txt AC 130 ms 21224 KB
04-min-02.txt AC 2 ms 2304 KB