답안 #558086

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
558086 2022-05-06T18:57:02 Z groshi 송금 (JOI19_remittance) C++17
100 / 100
345 ms 36644 KB
#include<iostream>
#include<queue>
using namespace std;
int t[2000000][2];
int jest[2000000];
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n,x,y;
    cin>>n;
    queue<int> kolejka;
    long long a=0,b=0;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        t[i][0]=x;
        t[i][1]=y;
        a+=x;
        b+=y;
        if(x>y)
        {
            kolejka.push(i);
            jest[i]=1;
        }
    }
    if(a!=0 && b==0)
    {
        cout<<"No";
        return 0;
    }
    while(!kolejka.empty())
    {
        x=kolejka.front();
        kolejka.pop();
        jest[x]=0;
        int oddaje=t[x][0]-t[x][1]+1;
        t[(x+1)%n][0]+=oddaje/2;
        if(oddaje%2==0)
            t[x][0]=t[x][1]-1;
        else t[x][0]=t[x][1];
        if(t[(x+1)%n][0]>t[(x+1)%n][1] && jest[(x+1)%n]==0)
            kolejka.push((x+1)%n);
    }

    int k=0;
    for(int i=0;i<n;i++)
        if(t[i][0]!=t[i][1])
            k=1;
    if(k==0)
        cout<<"Yes";
    else cout<<"No";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 336 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 336 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 328 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 0 ms 332 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 0 ms 340 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 336 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 328 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 0 ms 332 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 0 ms 340 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 0 ms 212 KB Output is correct
63 Correct 234 ms 33444 KB Output is correct
64 Correct 116 ms 17216 KB Output is correct
65 Correct 282 ms 34572 KB Output is correct
66 Correct 118 ms 17996 KB Output is correct
67 Correct 134 ms 20256 KB Output is correct
68 Correct 164 ms 23008 KB Output is correct
69 Correct 309 ms 34524 KB Output is correct
70 Correct 125 ms 17988 KB Output is correct
71 Correct 158 ms 20300 KB Output is correct
72 Correct 167 ms 22728 KB Output is correct
73 Correct 287 ms 34596 KB Output is correct
74 Correct 133 ms 18112 KB Output is correct
75 Correct 146 ms 20300 KB Output is correct
76 Correct 166 ms 22828 KB Output is correct
77 Correct 345 ms 34568 KB Output is correct
78 Correct 153 ms 27744 KB Output is correct
79 Correct 161 ms 27800 KB Output is correct
80 Correct 179 ms 27812 KB Output is correct
81 Correct 174 ms 27744 KB Output is correct
82 Correct 100 ms 19984 KB Output is correct
83 Correct 100 ms 11964 KB Output is correct
84 Correct 97 ms 11988 KB Output is correct
85 Correct 234 ms 36644 KB Output is correct
86 Correct 253 ms 36528 KB Output is correct
87 Correct 184 ms 28992 KB Output is correct
88 Correct 192 ms 28880 KB Output is correct