PPaste!

scratchCode solutions

Home - All the pastes - Authored by Thooms

Raw version

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Machine code

# written by pssolanki

def LetMeDoIt(k):
    s = k-1
    for x in range(1, k):
        if '7' in str(s) or '7' in str(x):
            s -= 1
            continue
        elif '7' not in str(s) or '7' not in str(x):
            return str(x) + ' ' + str(s)

def MainApp():
    t = int(input())

    for _ in range(t):
        k = int(input())

        result = LetMeDoIt(k)
        print(result)
        
if __name__ == '__main__':
    MainApp()

#=======================================

#studds solution

# written by pssolanki

def LetMeDoIt(brr, n, grr):
    f = []

    for _ in range(n):
        if min(brr) < min(grr):
            f.append(min(brr))
            brr.remove(min(brr))
            continue
        elif min(grr) < min(brr):
            f.append(min(grr))
            grr.remove(min(grr))
            continue
        elif min(brr) == min(grr):
            f.append(min(grr))
            grr.remove(min(grr))
            continue
        
    if len(f) != n*2:
        return 'NO'
    else:
        return 'YES'

def MainApp():
    t = int(input())

    for _ in range(t):
        n = int(input())
        brr = list(map(int, input().split()))
        grr = list(map(int, input().split()))
        result = LetMeDoIt(brr, n, grr)
        print(result)
        
if __name__ == '__main__':
    MainApp()

#================================

#0 sum range solution

# written by pssolanki

def LetMeDoIt(arr, N):
    subs = 0

    for x in range(N):
        for p in range(x+1, N):
            if sum(arr[x:p]) == 0:
                subs += 1
            else:
                continue
    return subs

def MainApp():
    N = int(input())
    arr = list(map(int, input().split()))

    result = LetMeDoIt(arr, N)
    print(result)
        
if __name__ == '__main__':
    MainApp()

#=====================