#include <iostream>
#include <math.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stdio.h>
#include <unordered_map>
#include <cstring>
#include <numeric>
#include <set>
#define Kaspárov main
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
//\\ PRINCIPAL \\//
#define int long long
#define ull unsigned long long
#define ios ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(0); //srand(time(NULL));
//\\ VECTOR \\//
#define vi vector<int>
#define pii pair<int, int>
#define ti pair<int, pii>
#define vii vector<vector<int>>
#define vpii vector<pair<int, int>>
#define vti vector<ti>
#define vipii vector<vector<pair<int, int>>>
#define pb push_back
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
#define ordenar(x) sort( x.begin(), x.end() )
#define ordenarA(x,n) sort( x, x + n )
#define dbg(x) cout<<#x<<" "<<x<<"\n"
#define forn(i, n) for(int i = 0; i<n; ++i)
//\\ OPERACIONES RAPIDAS \\//
#define sf(n) scanf("%d", &n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define sfl(n) scanf("%lld", &n)
#define sffl(n,m) scanf("%lld%lld",&n,&m)
#define pf(n) printf("%d\n",n)
#define pfl(n) printf("%lld ",n)
#define pfs(s) printf("%s\n",s)
bool cmp1(pii a, pii b){
return a.ss<b.ss;
}
bool cmp2(ti a, ti b){
return a.ss.ff<b.ss.ff;
}
bool cmp3(ti a, ti b){
return a.ss.ss<b.ss.ss;
}
//\\ CODEFORCES \\//
#define ri(v, size) vector<int> v(size); for(int& x: v) cin>>x;
#define rpi(v, size) vector<pair<int, int>> v(size); for(auto& x: v) cin>>x.ff>>x.ss;
#define rt(n, size) vti(size); for(auto& x: v) cin>>x.ff>>x.ss.ff>>x.ss.ss;
#define srt(v) sort(all(v))
#define srt1(v) sort(all(v), cmp1)
#define srt2(v) sort(all(v), cmp2)
#define srt3(v) sort(all(v), cmp3)
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
inline void es(bool a){
string res = a==true ? "YES\n" : "NO\n";
cout<<res;
}
const int MAXN = 2e5+5, mod = 1e9+7;
const int INF = 1e18;
inline void mos(vector<int> a){
for(int x: a) cout<<x<<" ";
cout<<"\n";
}
void setIO(string name = "") {
if (!name.empty()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
void solve();
int32_t main(){
setIO();
ios;
int t = 1;
while(t--){
solve();
}
fflush(stdin);
fflush(stdout);
}
void solve(){
int n, d, m; cin>>n>>d>>m;
vpii v;
forn(i, m){
int a; cin>>a;
v.pb({a, i+1});
}
srt(v);
int l = 1, r = m;
while(r>l){
int mid = l + (r-l)/2;
int i = 0, j = 1;
int maxn = 0;
while(i<m){
maxn = max(maxn, j-v[i].ff);
i+= mid;
++j;
}
if(maxn<=d){
r = mid;
}
else l = mid+1;
}
cout<<l<<"\n";
int i = 0;
for(int k = 0; k<n; ++k, i+=l){
for(int j = i; j<min(m, i+l); ++j) cout<<v[j].ss<<" ";
cout<<"0\n";
}
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
컴파일 시 표준 에러 (stderr) 메시지
jobs.cpp: In function 'void setIO(std::string)':
jobs.cpp:91:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
91 | freopen((name + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:92:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
92 | freopen((name + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |