QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93870#64. NaanHe_Ren0 28ms28616kbC++141.1kb2023-04-03 14:47:242023-04-03 14:47:27

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-03 14:47:27]
  • 评测
  • 测评结果:0
  • 用时:28ms
  • 内存:28616kb
  • [2023-04-03 14:47:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 LL;
typedef pair<int,int> pii;
const int MAXN = 2e3 + 5;

using Data = pair<ll,int>;

LL cmp(Data A,Data B)
{
	return (LL)A.first * B.second - (LL)A.second * B.first;
}

int a[MAXN][MAXN];
Data p[MAXN][MAXN];

int main(void)
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			scanf("%d",&a[i][j]);
	
	for(int k=1; k<=n; ++k)
	{
		ll need = accumulate(a[k]+1, a[k]+m+1, 0ll);
		ll sum = 0;
		for(int i=1,j=1; i<=n; ++i)
		{
			ll cur = need * i;
			while(sum + (ll)a[j] * n < cur)
				sum += (ll)a[j] * n, ++j;
			
			p[k][i] = {cur - sum + ll(j-1) * n * a[k][j], n * a[k][j]};
		}
	}
	
	static int id[MAXN];
	static bool vis[MAXN];
	for(int i=1; i<=n; ++i)
	{
		Data mn = {-1, -1};
		for(int j=1; j<=n; ++j)
			if(!vis[j] && (mn.first == -1 || cmp(p[j][i], mn) < 0))
			{
				id[i] = j;
				mn = p[j][i];
			}
		vis[id[i]] = 1;
		
		if(i < n)
			printf("%lld %d\n",mn.first,mn.second);
	}
	for(int i=1; i<=n; ++i)
		printf("%d ",id[i]);
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5640kb

input:

2 1516
42058 25892 51128 40494 78380 30332 47660 58339 90812 50469 28184 75581 61837 25051 90975 98279 81022 90217 31015 72984 89884 68399 47215 10071 43418 61089 91302 96661 47701 86531 26050 80503 54870 1405 71971 39883 82485 66816 115 49358 86761 24392 32521 87048 19107 56752 23862 96755 80318 44...

output:

76559878 113180
2 1 

result:

wrong answer 

Subtask #2:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 2ms
memory: 5556kb

input:

2 1168
4 10 7 6 10 3 9 5 7 10 9 7 9 1 5 9 8 5 3 4 5 2 10 7 6 2 4 5 2 4 4 8 10 1 2 9 1 3 6 6 3 8 8 1 8 4 5 6 7 9 2 2 3 2 8 9 4 7 8 9 8 6 8 4 6 3 5 4 5 1 5 5 10 8 2 4 8 1 9 1 7 6 10 4 4 2 3 4 6 3 2 9 1 10 3 8 8 10 8 1 8 10 8 6 1 1 3 8 2 6 8 6 8 9 8 1 7 6 9 3 2 1 5 2 8 6 4 4 1 2 9 2 6 6 8 2 4 2 2 4 6 4...

output:

6280 8
1 2 

result:

wrong answer 

Subtask #3:

score: 0
Wrong Answer

Test #42:

score: 0
Wrong Answer
time: 28ms
memory: 28616kb

input:

563 467
8049 85539 27182 28071 94216 41847 50021 12220 27028 36160 7314 23133 44548 80654 65291 17329 61691 98590 68874 59735 6789 7383 17300 46373 35858 95819 15891 55598 25928 20662 99160 79046 1004 1901 33290 20640 86369 3246 36921 56090 11582 48092 48473 32198 80924 42208 80056 24593 43827 68820...

output:

22348400 56010618
44837792 56053406
67554909 55117700
87046568 53177039
115039550 55843407
136340022 55014108
162028615 55497725
187458160 55949814
207325818 54873921
225478560 53473740
252542840 54339071
283976676 55742067
308300174 55785418
328114374 55104188
361119795 56222869
378533120 55043947
...

result:

wrong answer