QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#791815#5512. Stone Arranging 2vinaka35 21ms10520kbC++141.6kb2024-11-28 21:09:142024-11-28 21:09:14

Judging History

你现在查看的是最新测评结果

  • [2024-11-28 21:09:14]
  • 评测
  • 测评结果:35
  • 用时:21ms
  • 内存:10520kb
  • [2024-11-28 21:09:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define NAME ""
#define ll long long
#define pii pair < int , int >
#define fi first
#define se second
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i ++)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i --)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i ++)
#define bit(x, i) (((x) >> (i)) & 1ll)
#define mask(x) (1ll << (x))
#define mem(f, x) memset(f, x, sizeof(f))
#define sz(x) (int32_t) (x.size())

const int nmax = 2e5;
int a[nmax + 7], f[nmax + 7];
vector < int > pos[nmax + 7];

int find_left(int i) {
  return (f[i] == i ? i : find_left(f[i]));
}

signed main() {
  for(string s: {NAME, ""}) {
    if (fopen((s + ".inp").c_str(), "r")) {
      freopen((s + ".inp").c_str(), "r", stdin);
      freopen((s + ".out").c_str(), "w", stdout);
      break;
    }
  }
  cin.tie(0)->sync_with_stdio(0);

  int n;
  cin >> n;

  vector < int > val;
  FOR(i, 1, n) {
    cin >> a[i];
    val.push_back(a[i]);
  }

  sort(val.begin(), val.end());
  val.erase(unique(val.begin(), val.end()), val.end());

  FOR(i, 1, n) {
    int x = lower_bound(val.begin(), val.end(), a[i]) - val.begin();
    f[i] = i;

    while (!pos[x].empty()) {
      int l = pos[x].back();
      pos[x].pop_back();
      if (f[l] != l) {
        continue;
      }

      int r = i - 1;
      while (r > l) {
        int tmp = find_left(r);
        f[r] = l;
        r = tmp - 1;
      }
    }
    pos[x].push_back(i);
  }

  FOR(i, 1, n) {
    cout << a[find_left(i)] << "\n";
  }

  return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 25
Accepted
time: 2ms
memory: 9540kb

input:

1
1

output:

1

result:

ok single line: '1'

Test #2:

score: 25
Accepted
time: 2ms
memory: 8512kb

input:

2
1
1

output:

1
1

result:

ok 2 lines

Test #3:

score: 25
Accepted
time: 2ms
memory: 9232kb

input:

3
1
1
1

output:

1
1
1

result:

ok 3 lines

Test #4:

score: 25
Accepted
time: 2ms
memory: 8520kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 2000 lines

Test #5:

score: 25
Accepted
time: 0ms
memory: 8480kb

input:

1
2

output:

2

result:

ok single line: '2'

Test #6:

score: 25
Accepted
time: 2ms
memory: 9636kb

input:

2
2
2

output:

2
2

result:

ok 2 lines

Test #7:

score: 25
Accepted
time: 2ms
memory: 8792kb

input:

3
2
2
2

output:

2
2
2

result:

ok 3 lines

Test #8:

score: 25
Accepted
time: 2ms
memory: 8636kb

input:

2000
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 2000 lines

Test #9:

score: 25
Accepted
time: 2ms
memory: 9968kb

input:

2000
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
33497...

output:

334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
334978097
...

result:

ok 2000 lines

Test #10:

score: 25
Accepted
time: 2ms
memory: 9288kb

input:

2000
2
1
2
2
1
1
1
2
2
2
1
1
2
2
1
1
2
2
2
2
2
1
2
1
2
2
1
2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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 2000 lines

Test #15:

score: 25
Accepted
time: 2ms
memory: 8604kb

input:

2000
81888042
43067133
107207954
11840122
12213120
1564709
591852273
88838690
961663051
516561909
168803248
844631608
873195256
827482724
743609376
619362989
538294587
82184630
144127319
243409882
211682139
271003483
663591071
168473717
654369346
16498799
591919038
700712177
385773734
618206739
8131...

output:

81888042
43067133
107207954
11840122
12213120
1564709
591852273
88838690
961663051
516561909
168803248
844631608
873195256
827482724
743609376
619362989
538294587
82184630
144127319
243409882
211682139
271003483
663591071
168473717
654369346
16498799
591919038
700712177
385773734
618206739
813177482...

result:

ok 2000 lines

Test #16:

score: 25
Accepted
time: 2ms
memory: 8400kb

input:

2000
885745611
10531340
864341459
215264744
300047319
287916141
644603625
884166447
420412412
20068650
590534965
653358937
990188463
990316905
998312402
558306521
958686996
980116759
160902156
540498688
104465002
553013905
427573746
519316677
185497721
791572866
825112521
486213608
474133783
1868877...

output:

885745611
10531340
864341459
215264744
300047319
287916141
644603625
884166447
420412412
20068650
590534965
653358937
990188463
990316905
998312402
558306521
958686996
980116759
160902156
540498688
104465002
553013905
427573746
519316677
185497721
791572866
825112521
486213608
474133783
186887702
27...

result:

ok 2000 lines

Test #17:

score: 25
Accepted
time: 2ms
memory: 9080kb

input:

2000
124748890
124748890
124748890
815254336
124748890
815254336
815254336
124748890
124748890
124748890
815254336
124748890
124748890
815254336
815254336
815254336
124748890
124748890
124748890
124748890
815254336
815254336
815254336
124748890
124748890
815254336
815254336
815254336
815254336
12474...

output:

124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
124748890
...

result:

ok 2000 lines

Test #18:

score: 25
Accepted
time: 2ms
memory: 8308kb

input:

2000
401665219
401665219
401665219
27125575
401665219
401665219
401665219
27125575
401665219
27125575
27125575
401665219
401665219
27125575
401665219
401665219
27125575
27125575
27125575
401665219
27125575
401665219
27125575
401665219
27125575
27125575
27125575
27125575
401665219
401665219
401665219...

output:

401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
401665219
...

result:

ok 2000 lines

Test #19:

score: 25
Accepted
time: 2ms
memory: 9268kb

input:

2000
810060218
522476642
810060218
522476642
522476642
522476642
810060218
810060218
810060218
522476642
522476642
810060218
810060218
810060218
810060218
810060218
522476642
810060218
810060218
522476642
810060218
810060218
810060218
522476642
522476642
522476642
810060218
810060218
522476642
52247...

output:

810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
810060218
...

result:

ok 2000 lines

Test #20:

score: 25
Accepted
time: 2ms
memory: 8516kb

input:

2000
401575885
661633480
401575885
661633480
661633480
661633480
401575885
661633480
401575885
401575885
661633480
401575885
661633480
401575885
401575885
401575885
661633480
401575885
661633480
661633480
401575885
401575885
401575885
661633480
661633480
661633480
401575885
661633480
401575885
66163...

output:

401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
401575885
...

result:

ok 2000 lines

Test #21:

score: 0
Wrong Answer
time: 2ms
memory: 8488kb

input:

2000
8679749
689251055
488931635
8679749
689251055
488931635
488931635
488931635
689251055
488931635
488931635
488931635
488931635
8679749
689251055
689251055
488931635
8679749
488931635
689251055
8679749
689251055
488931635
8679749
488931635
8679749
8679749
689251055
488931635
8679749
488931635
867...

output:

8679749
8679749
8679749
8679749
689251055
689251055
689251055
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
8679749
867974...

result:

wrong answer 5th lines differ - expected: '8679749', found: '689251055'

Subtask #2:

score: 35
Accepted

Test #29:

score: 35
Accepted
time: 14ms
memory: 10276kb

input:

200000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #30:

score: 35
Accepted
time: 14ms
memory: 10364kb

input:

200000
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200000 lines

Test #32:

score: 35
Accepted
time: 18ms
memory: 10368kb

input:

200000
1
1
2
2
1
1
1
2
1
2
2
1
1
2
2
1
1
2
2
2
2
1
2
1
1
2
2
1
2
2
1
2
1
2
1
1
1
2
1
2
1
1
1
1
2
2
1
1
2
1
1
2
1
2
2
1
1
1
1
2
2
1
2
2
2
1
1
2
2
2
1
1
1
1
2
1
1
2
1
2
2
1
2
1
2
2
1
1
2
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
2
2
2
2
2
1
2
2
2
1
2
1
1
2
1
2
1
2
2
1
2
2
2
2
1
2
1
1
2
2
1
2
2
2
2
2
2
1
2
1
1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #33:

score: 35
Accepted
time: 17ms
memory: 10392kb

input:

200000
1
2
2
2
2
2
1
1
1
1
1
2
1
2
2
2
1
1
2
2
2
1
2
1
1
1
2
1
1
1
2
2
1
1
1
2
2
1
2
2
2
2
2
1
1
1
1
2
1
2
2
1
1
1
2
1
2
2
1
1
1
1
2
1
1
1
2
2
1
2
2
1
1
1
1
1
2
2
1
1
2
2
1
1
2
1
1
2
1
2
2
2
1
2
1
1
2
1
2
2
2
1
1
2
1
2
1
2
2
2
1
2
1
2
2
1
1
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 lines

Test #35:

score: 35
Accepted
time: 17ms
memory: 10420kb

input:

200000
1
1
2
1
2
1
2
1
1
1
2
2
1
2
1
2
2
1
1
2
1
1
2
2
2
1
2
2
2
1
2
2
2
1
2
1
2
1
2
1
1
1
2
2
2
1
1
1
1
2
1
2
1
1
2
2
1
2
2
1
2
1
2
1
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
1
2
2
1
2
2
1
2
2
1
1
2
2
1
2
2
1
1
2
1
1
2
1
1
1
2
1
1
1
2
2
1
1
1
1
2
2
2
1
1
1
1
1
1
2
1
2
2
1
1
1
1
2
1
1
2
1
2
2
2
1
2
1
1
1
1
1
2...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #36:

score: 35
Accepted
time: 18ms
memory: 10328kb

input:

200000
2
1
2
2
1
1
2
1
1
1
1
2
1
1
2
2
2
1
2
2
2
1
2
2
1
2
1
1
1
1
1
2
2
2
2
2
1
2
2
2
1
2
1
1
1
2
2
2
2
1
2
2
2
1
1
1
2
2
2
1
1
1
2
2
1
2
2
1
1
1
2
1
2
2
1
2
2
1
2
2
2
2
2
1
2
2
2
2
2
1
2
1
1
1
1
1
1
2
2
2
1
2
2
2
2
1
2
2
2
1
1
2
2
1
2
2
2
2
1
1
1
2
2
2
2
1
2
1
2
1
2
1
1
2
2
2
1
2
1
1
2
1
2
2
2
2
1...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200000 lines

Test #37:

score: 35
Accepted
time: 21ms
memory: 10432kb

input:

200000
1
1
1
1
1
1
1
2
1
2
2
1
1
2
2
1
1
1
1
1
1
1
1
2
1
1
2
1
2
2
2
2
1
1
1
1
1
2
2
1
2
2
2
1
1
2
2
1
2
1
1
2
2
2
2
2
2
1
2
2
2
1
1
2
1
1
1
1
1
2
2
1
1
1
2
2
2
1
1
1
1
1
1
2
2
2
2
2
2
1
2
2
1
2
2
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
2
2
1
2
1
1
2
1
2
2
2
2
1
2
2
1
1
1
2
2
1
1
1
2
1
2
2
1
1
1
2
1
2
2
1
2
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Test #38:

score: 35
Accepted
time: 21ms
memory: 10408kb

input:

200000
1
2
1
2
2
1
2
2
1
2
1
1
1
1
2
1
1
2
1
1
2
1
1
1
1
2
1
1
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2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200000 lines

Test #40:

score: 35
Accepted
time: 18ms
memory: 10436kb

input:

200000
2
2
2
2
2
1
2
1
1
1
1
1
1
1
2
2
2
2
1
1
2
1
1
2
2
1
1
2
1
1
2
1
1
2
1
1
1
2
1
2
2
2
2
1
2
2
1
2
2
1
2
2
2
2
1
2
2
2
2
1
2
1
2
1
1
2
1
1
2
1
1
2
2
1
1
2
2
1
2
1
2
2
1
2
1
1
2
2
1
1
2
2
2
1
2
1
2
1
1
2
1
2
2
1
1
1
2
1
1
2
1
2
1
2
2
2
2
2
2
2
2
1
1
2
2
1
1
1
1
2
2
1
2
1
1
1
1
2
1
2
2
2
2
1
2
1
2...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200000 lines

Test #41:

score: 35
Accepted
time: 14ms
memory: 10520kb

input:

200000
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
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2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200000 lines

Test #43:

score: 35
Accepted
time: 18ms
memory: 10324kb

input:

200000
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200000 lines

Subtask #3:

score: 0
Skipped

Dependency #1:

0%