Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <fstream>
- #include <iomanip>
- #include <cstdio>
- #include <cstdlib>
- #include <algorithm>
- #include <queue>
- #include <stack>
- #include <set>
- #include <map>
- #include <list>
- #include <vector>
- #include <string>
- #include <cstring>
- #include <cmath>
- #include <ctime>
- #include <cassert>
- using namespace std;
- #define forn(i, n) for(int i = 0; i < (int)(n); i++)
- #define forn1(i, n) for(int i = 1; i <= (int)(n); i++)
- #define all(a) (a).begin(), (a).end()
- #define sz(a) (int)((a).size())
- #define mp make_pair
- #define pb push_back
- #define X first
- #define Y second
- #define x first
- #define y second
- #define y1 __y1
- #define sqr(x) ((x) * (x))
- typedef long long li;
- typedef long double ld;
- typedef pair<int, int> pt;
- const int INF = (int)(1e9);
- const li INF64 = (li)(INF) * (li)(INF);
- const ld eps = 1e-9;
- const ld pi = ld(3.1415926535897932384626433832795);
- bool in(int i, int j, int n, int m)
- {
- return i >= 1 && i <= n && j >= 1 && j <= m;
- }
- inline int myrand()
- {
- return (rand() ^ (rand() << 15));
- }
- const int dx[] = {-1, 1, 1, -1};
- const int dy[] = {1, 1, -1, -1};
- const int N = 1111;
- int a[N];
- int n, m;
- int s = 0;
- inline bool read()
- {
- if(!(cin >> n >> m))
- return false;
- forn(i, n)
- {
- assert(cin >> a[i]);
- s += a[i];
- }
- return true;
- }
- inline void solve()
- {
- for(int cnt = n; ; cnt++)
- {
- int ans = cnt - n;
- int need = m * cnt;
- need -= s;
- if(need < 0)
- continue;
- int lf = ans, rg = ans * 10;
- if(lf <= need && need <= rg)
- {
- cout << ans << endl;
- vector<int> res;
- int sum = need;
- while(ans > 0)
- {
- int c = -1;
- for(int cur = 1; cur <= 10; cur++)
- {
- int ost = sum - cur;
- if(ans - 1 <= ost && ost <= (ans - 1) * 10)
- {
- c = cur;
- break;
- }
- }
- assert(c >= 1 && c <= 10);
- res.pb(c);
- ans--;
- sum -= c;
- }
- assert(sum == 0 && ans == 0);
- forn(i, sz(res))
- cout << res[i] << ' ';
- cout << endl;
- return;
- }
- }
- return;
- }
- int main(){
- #ifdef _DEBUG
- assert(freopen("input.txt", "rt", stdin));
- assert(freopen("output.txt", "wt", stdout));
- #endif
- cout << setprecision(10) << fixed;
- cerr << setprecision(10) << fixed;
- srand(int(time(NULL)));
- assert(read());
- solve();
- cerr << "TIME == " << clock() << " ms" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment