Submission #1006387

# Submission time Handle Problem Language Result Execution time Memory
1006387 2024-06-24T00:03:49 Z AdamGS Naan (JOI19_naan) C++17
24 / 100
1 ms 348 KB
#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*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 time Memory Grader output
1 Incorrect 0 ms 344 KB Not a fair distribution.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Not a fair distribution.
2 Halted 0 ms 0 KB -