QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#498263#9133. Function with Many Maximumsucup-team3555AC ✓28ms10748kbC++20648b2024-07-30 10:31:482024-07-30 10:31:53

Judging History

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

  • [2024-07-30 10:31:53]
  • 评测
  • 测评结果:AC
  • 用时:28ms
  • 内存:10748kb
  • [2024-07-30 10:31:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long 

const int B=1e5,n=5e5;
vector<ll> a(n+1),f(n+1);

int main(){
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  for(ll i=1;i<=n;i++){
	if(8e22/i/(i+1)>1e12-i) a[i]=1e12-i;
	else a[i]=8e22/(i+1)/i;
  }
  ll sum=0;
  for(ll i=1;i<=n;i++){
	f[i]=sum+1ll*(i+1)*a[i];
    if(i>n-2*B&&f[i]<f[i-1]){
	  ll tmp=(f[i-1]-f[i])/(i+1)+1;
	  a[i]+=tmp,f[i]=sum+1ll*(i+1)*a[i];
	}
	sum+=a[i];
  }
  for(int i=n-2*B;i>=1;i--) a[i]=a[i+1]+1;
  for(int i=n;i>n-2*B;i-=2) a[i-1]-=f[i]-f[i-2];
  cout<<n<<'\n';
  for(int i=1;i<=n;i++) cout<<a[i]<<' ';
  return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 28ms
memory: 10744kb

input:

4

output:

500000
888880300069 888880300068 888880300067 888880300066 888880300065 888880300064 888880300063 888880300062 888880300061 888880300060 888880300059 888880300058 888880300057 888880300056 888880300055 888880300054 888880300053 888880300052 888880300051 888880300050 888880300049 888880300048 8888803...

result:

ok n=500000, max_a=888880300069, max_num=100000 >= 4

Test #2:

score: 0
Accepted
time: 28ms
memory: 10748kb

input:

100000

output:

500000
888880300069 888880300068 888880300067 888880300066 888880300065 888880300064 888880300063 888880300062 888880300061 888880300060 888880300059 888880300058 888880300057 888880300056 888880300055 888880300054 888880300053 888880300052 888880300051 888880300050 888880300049 888880300048 8888803...

result:

ok n=500000, max_a=888880300069, max_num=100000 >= 100000

Extra Test:

score: 0
Extra Test Passed