Submission #1006386

#TimeUsernameProblemLanguageResultExecution timeMemory
1006386AdamGSNaan (JOI19_naan)C++17
0 / 100
1 ms568 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const ll INF=1e9+7; const int LIM=2e3+7; ll T[LIM][LIM], sum[LIM], odw[LIM], n, l; bool mniejszy(pair<pair<ll,ll>,ll>a, pair<pair<ll,ll>,ll>b) { ll x=a.st.st*b.st.nd, y=b.st.st*a.st.nd; if(x==y) return a.nd<b.nd; return x<y; } pair<pair<ll,ll>,ll>nxt(pair<ll,ll>x) { pair<pair<ll,ll>,ll>ans={{INF, 1}, INF}; rep(i, n) if(!odw[i]) { ll p=x.st/x.nd, q=x.st-p*x.nd; ll a=(T[i][p]*q+x.nd-1)/x.nd; ll c=T[i][p]-a; if(c>=sum[i]) { a+=sum[i]; ans=min(ans, {{a+p*T[i][p], T[i][p]}, i}); continue; } ll d=p+1; while(c+T[i][d]<sum[i]) { c+=T[i][d]; ++d; } ll e=sum[i]-c; ans=min(ans, {{e+(d-1)*T[i][d], T[i][d]}, i}); } return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> l; rep(i, n) { rep(j, l) { cin >> T[i][j]; sum[i]+=T[i][j]; T[i][j]*=n; } } vector<ll>P; pair<ll,ll>akt={0, 1}; rep(i, n-1) { pair<pair<ll,ll>,ll>x=nxt(akt); P.pb(x.nd); odw[x.nd]=1; akt=x.st; cout << akt.st << " " << akt.nd << '\n'; } rep(i, n) if(!odw[i]) P.pb(i); for(auto i : P) cout << i+1 << " "; cout << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...