Submission #67524911


Source Code Expand

import javax.security.auth.login.AccountExpiredException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;


public class Main {
    private static void solve(int[][] a, int l, int r) {
int res=0;
        for (int[] ints : a) {
            if ((l>=ints[0]&&ints[1]>=r)){
                res++;
            }
        }
        System.out.println(res);
    }

    static int gcd(int a, int b) {
        if (a == 0)
            return b;

        return gcd(b % a, a);
    }


    static void shuffleArray(int[] ar) {
        // If running on Java 6 or older, use `new Random()` on RHS here
        Random rnd = ThreadLocalRandom.current();
        for (int i = ar.length - 1; i > 0; i--) {
            int index = rnd.nextInt(i + 1);
            // Simple swap
            int a = ar[index];
            ar[index] = ar[i];
            ar[i] = a;

        }
    }

    static void shuffleArray(char[] ar) {
        // If running on Java 6 or older, use `new Random()` on RHS here
        Random rnd = ThreadLocalRandom.current();
        for (int i = ar.length - 1; i > 0; i--) {
            int index = rnd.nextInt(i + 1);
            // Simple swap
            char a = ar[index];
            ar[index] = ar[i];
            ar[i] = a;

        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int t = 1;
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            StringBuilder builder = new StringBuilder();
            long s=0;
            for (int j = 0; j < n; j++) {
                String c = sc.next();
                long cnt = sc.nextLong();
                s+=cnt;
                if (s>100){
                    System.out.println("Too Long");
                    return;
                }
                for (int k = 0; k < cnt; k++) {
                    builder.append(c);
                }
            }
            System.out.println(builder);
        }
    }

    static void swap(int[] a, int i, int j) {
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }

    static void swap(char[] a, int i, int j) {
        char t = a[i];
        a[i] = a[j];
        a[j] = t;
    }

    private static <T> void swap(T[] elements, int a, int b) {
        T tmp = elements[a];
        elements[a] = elements[b];
        elements[b] = tmp;
    }

    static class UF {
        private int[] parent;
        private int[] rank;

        public UF(int n) {
            parent = new int[n + 1];
            rank = new int[n + 1];
            for (int i = 0; i < n; i++) {
                parent[i] = i;
                rank[i] = 1;
            }
        }

        public int find(int x) {
            if (parent[x] != x) {
                parent[x] = find(parent[x]);
            }
            return parent[x];
        }

        public void union(int x, int y) {
            int rootX = find(x);
            int rootY = find(y);


            if (rank[rootX] < rank[rootY]) {
                parent[rootX] = rootY;
                rank[rootY] += rank[rootX];
            } else if (rank[rootX] >= rank[rootY]) {
                parent[rootY] = rootX;
                rank[rootX] += rank[rootY];
            }
        }
    }

    static class BIT {

        // The size of the array holding the Fenwick tree values
        final int N;

        // This array contains the Fenwick tree ranges
        private long[] tree;

        // Create an empty Fenwick Tree with 'sz' parameter zero based.
        public BIT(int sz) {
            tree = new long[(N = sz + 1)];
        }

        // Construct a Fenwick tree with an initial set of values.
        // The 'values' array MUST BE ONE BASED meaning values[0]
        // does not get used, O(n) construction.
        public BIT(long[] values) {

            if (values == null) {
                throw new IllegalArgumentException("Values array cannot be null!");
            }

            N = values.length;
            values[0] = 0L;

            // Make a clone of the values array since we manipulate
            // the array in place destroying all its original content.
            tree = values.clone();

            for (int i = 1; i < N; i++) {
                int parent = i + lsb(i);
                if (parent < N) {
                    tree[parent] += tree[i];
                }
            }
        }

        // Returns the value of the least significant bit (LSB)
        // lsb(108) = lsb(0b1101100) = 0b100 = 4
        // lsb(104) = lsb(0b1101000) = 0b1000 = 8
        // lsb(96) = lsb(0b1100000) = 0b100000 = 32
        // lsb(64) = lsb(0b1000000) = 0b1000000 = 64
        private static int lsb(int i) {

            // Isolates the lowest one bit value
            return i & -i;

            // An alternative method is to use the Java's built in method
            // return Integer.lowestOneBit(i);

        }

        // Computes the prefix sum from [1, i], O(log(n))
        private long prefixSum(int i) {
            long sum = 0L;
            while (i != 0) {
                sum += tree[i];
                i &= ~lsb(i); // Equivalently, i -= lsb(i);
            }
            return sum;
        }

        // Returns the sum of the interval [left, right], O(log(n))
        public long sum(int left, int right) {
            if (right < left) {
                throw new IllegalArgumentException("Make sure right >= left");
            }
            return prefixSum(right) - prefixSum(left - 1);
        }

        // Get the value at index i
        public long get(int i) {
            return sum(i, i);
        }

        // Add 'v' to index 'i', O(log(n))
        public void add(int i, long v) {
            while (i < N) {
                tree[i] += v;
                i += lsb(i);
            }
        }

        // Set index i to be equal to v, O(log(n))
        public void set(int i, long v) {
            add(i, v - sum(i, i));
        }

        @Override
        public String toString() {
            return Arrays.toString(tree);
        }
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long[] readArrayLong(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }

        int[] readArrayInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Submission Info

Submission Time
Task B - String Too Long
User kiriII
Language Java (OpenJDK 17)
Score 200
Code Size 7553 Byte
Status AC
Exec Time 42 ms
Memory 34684 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 22
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 39 ms 34632 KiB
00_sample_01.txt AC 39 ms 34684 KiB
00_sample_02.txt AC 39 ms 34404 KiB
00_sample_03.txt AC 39 ms 34476 KiB
01_test_00.txt AC 40 ms 34448 KiB
01_test_01.txt AC 41 ms 34496 KiB
01_test_02.txt AC 39 ms 34540 KiB
01_test_03.txt AC 42 ms 34468 KiB
01_test_04.txt AC 39 ms 34392 KiB
01_test_05.txt AC 40 ms 34408 KiB
01_test_06.txt AC 41 ms 34488 KiB
01_test_07.txt AC 41 ms 34472 KiB
01_test_08.txt AC 41 ms 34488 KiB
01_test_09.txt AC 41 ms 34448 KiB
01_test_10.txt AC 39 ms 34472 KiB
01_test_11.txt AC 39 ms 34664 KiB
01_test_12.txt AC 39 ms 34436 KiB
01_test_13.txt AC 39 ms 34476 KiB
01_test_14.txt AC 38 ms 34412 KiB
01_test_15.txt AC 40 ms 34624 KiB
01_test_16.txt AC 40 ms 34404 KiB
01_test_17.txt AC 39 ms 34460 KiB