QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#744819#5674. Sum of RemaindersMattTheNub#AC ✓0ms3820kbC++232.2kb2024-11-13 23:38:232024-11-13 23:38:24

Judging History

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

  • [2024-11-13 23:38:24]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3820kb
  • [2024-11-13 23:38:23]
  • 提交

answer

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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

template <class T> using v = vector<T>;
using ll = long long;
using dd = long double;
using int2 = pair<int, int>;
using ll2 = pair<ll, ll>;
using dd2 = pair<dd, dd>;

#define f first
#define s second
#define all(x) begin(x), end(x)
istream &__cin = cin;
#ifdef DEV_MODE
#include "debug.h"
__cinwrapper __cin_wrapper;
#define cin __cin_wrapper
#else
#define dbg(...)
#define dbg2d(...)
#endif

template <class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
  in >> p.first >> p.second;
  return in;
}
template <class T> istream &operator>>(istream &in, v<T> &v) {
  for (auto &x : v)
    in >> x;
  return in;
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
 _______________________________________
( If you don't fail at least 90% of the )
( time, you're not aiming high enough.  )
(                                       )
( - Alan Kay                            )
 ---------------------------------------
        o   ^__^
         o  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
*/

const bool INTERACTIVE = false;
const bool MULTITEST = false;
/******************************************************************************/

#pragma region templates

#pragma endregion templates

void solve() {
  int n;
  cin >> n;
  v<int> s(n);
  cin >> s;

  v<int> c(n), ans;
  c[0] = s[0];
  for (int i = 1; i < n; i++) {
    int cur = s[i];
    for (auto x : ans) {
      cur -= (i + 1) % x;
    }
    c[i] = cur / (i + 1);

    for (int j = 0; j < c[i - 1] - c[i]; j++) {
      ans.push_back(i + 1);
    }
  }
  dbg(c);

  cout << ans.size() << ' ';
  for (auto x : ans) {
    cout << x << ' ';
  }
}

int main() {
#ifdef DEV_MODE
  debug_start(INTERACTIVE, "b.txt");
#else
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  int t;
  if (MULTITEST)
    cin >> t;
  else
    t = 1;
  while (t--)
    solve();

#ifdef DEV_MODE
  debug_exit(INTERACTIVE);
#endif
}
#ifdef DEV_MODE
#include "debug.cpp"
#endif

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3492kb

input:

16
4 6 10 12 6 8 12 14 18 10
3 5 9 11 5 7

output:

4 2 5 5 11 

result:

ok single line: '4 2 5 5 11 '

Test #2:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

20
3 6 6 9 12 6 2 5 5 8
11 5 8 4 4 7 10 4 7 10

output:

3 3 6 7 

result:

ok single line: '3 3 6 7 '

Test #3:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

40
7 14 21 28 35 42 42 49 56 63
70 65 59 45 37 44 51 58 65 72
72 79 86 57 39 33 40 26 33 25
32 39 46 53 53 48 55 62 56 63

output:

7 7 12 13 14 15 24 25 

result:

ok single line: '7 7 12 13 14 15 24 25 '

Test #4:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

60
7 14 21 28 35 42 49 56 63 70
77 72 79 86 93 100 90 97 85 92
99 106 113 108 115 122 102 109 116 123
99 106 113 103 110 105 112 100 107 114
121 86 93 56 63 70 77 72 79 86
76 83 90 70 77 84 72 79 86 81

output:

7 12 17 19 27 31 42 44 

result:

ok single line: '7 12 17 19 27 31 42 44 '

Test #5:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

20
1 2 3 4 5 6 7 8 0 1
2 3 4 5 6 7 8 0 1 2

output:

1 9 

result:

ok single line: '1 9 '

Test #6:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

30
2 4 6 8 10 12 14 16 18 20
11 13 2 4 6 8 10 12 14 16
18 9 11 13 15 4 6 8 10 12

output:

2 11 13 

result:

ok single line: '2 11 13 '

Test #7:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

40
9 18 24 33 42 42 51 60 66 65
74 74 70 79 70 47 56 56 46 45
51 60 69 45 54 50 56 65 74 49
58 35 41 50 59 59 68 58 51 50

output:

9 3 6 10 13 15 16 16 19 24 

result:

ok single line: '9 3 6 10 13 15 16 16 19 24 '

Test #8:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

60
7 14 21 28 35 42 49 48 55 62
69 76 83 76 83 82 89 96 103 110
117 124 131 130 137 144 151 144 151 158
165 164 171 144 151 158 165 172 179 138
145 138 145 108 70 77 84 83 90 47
54 61 68 75 82 67 74 81 88 95

output:

7 8 14 34 40 44 45 50 

result:

ok single line: '7 8 14 34 40 44 45 50 '

Test #9:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

70
3 6 9 12 15 18 21 24 27 30
33 36 39 42 45 48 51 54 57 60
63 66 69 72 75 78 81 84 87 60
63 66 69 72 75 78 81 84 87 90
93 96 99 102 60 63 66 69 72 75
78 81 84 33 36 39 42 45 48 21
24 27 30 33 36 39 42 45 48 51

output:

3 30 45 54 

result:

ok single line: '3 30 45 54 '

Test #10:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

30
5 10 15 16 21 20 25 26 31 26
31 26 31 36 41 42 30 29 15 6
11 16 21 16 21 26 31 32 37 26

output:

5 4 6 10 17 19 

result:

ok single line: '5 4 6 10 17 19 '