QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#792116#9275. Integer Number Formatbulijiojiodibuliduo#RE 0ms0kbC++171.6kb2024-11-29 00:08:482024-11-29 00:08:49

Judging History

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

  • [2024-11-29 00:08:49]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-29 00:08:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=1111111;
const int inf=1<<30;
short pre[N][17];
int dp[N][17],cnt[N];
int x,y,n;
int main() {
	scanf("%d%d%d",&x,&y,&n);
	rep(i,0,n) {
		int a;
		scanf("%d",&a),cnt[a-x]+=1;
	}
	y-=x;
	for (int i=0;i<=y+70000;i++)
		cnt[i]+=cnt[i-1];
	int ans=inf,anso=-1;;
	for (int i=0;i<=y+70000;i++) {
		dp[i][0]=inf;
		for (int j=1;j<=16;j++) {
			dp[i][j]=inf;
			for (int g=0;g<=4;g++) {
				int v=inf;
				if (i-(1<<(4*g))<0&&j==1) {
					v=cnt[i]*(g+1);
				} else {
					v=dp[i-(1<<(4*g))][j-1]+(cnt[i]-cnt[i-(1<<(4*g))])*(g+1);
				}
				if (v<dp[i][j]) {
					dp[i][j]=v;
					pre[i][j]=g;
				}
			}
		}
		if (i>=y&&dp[i][16]<ans) {
			ans=dp[i][16];
			anso=i;
		}
	}
	per(i,1,17) {
		int g=pre[anso][i];
		printf("%d %d\n",g,anso-(1<<(4*g))+1+x);
		//reg.pb(mp(anso-(1<<(4*g))+1+x,g));
		anso=anso-(1<<(4*g));
	}
	//printf("%d\n",ans-n);
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

0 15
16
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

output:


result: