QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#146827#1772. Antenna AnalysismojospyWA 475ms47256kbC++14909b2023-08-22 17:03:042023-08-22 17:03:06

Judging History

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

  • [2023-08-22 17:03:06]
  • 评测
  • 测评结果:WA
  • 用时:475ms
  • 内存:47256kb
  • [2023-08-22 17:03:04]
  • 提交

answer

#include<iostream>
#include<queue>
#include<set>
using namespace std;
const int N=4e5+6;
long long int res[N],a[N];
int n,c;
class cmp1{
	public:
	bool operator()(int i,int j){
		return c*i-a[i]>c*j-a[j];
	}
};
class cmp2{
	public:
	bool operator()(int i,int j){
		return c*i+a[i]>c*j+a[j];
	}
	
};

int main(){
	cin>>n>>c;
	cout<<N;
	for(int i=0;i<n;++i) cin>>a[i];
	multiset<int,cmp1> s1;
	multiset<int,cmp2> s2;
	
	s1.insert(0);
	for(int i=1;i<n;++i){
		for(auto it=s1.begin();it!=s1.end();++it){
			if(a[i]>=a[*it]){
				res[i]=max(res[i],a[i]-c*i+c*(*it)-a[*it]);
				break;
			}
		}
		s1.insert(i);
	}
	
	s2.insert(0);
	for(int i=1;i<n;++i){
		for(auto it=s2.begin();it!=s2.end();++it){
			if(a[i]<=a[*it]){
				res[i]=max(res[i],-a[i]-c*i+c*(*it)+a[*it]);
				break;
			}
		}	
		s2.insert(i);
	}
	for(int i=0;i<n;++i) cout<<res[i]<<" ";
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 475ms
memory: 47256kb

input:

400000 1
647761 970495 559170 744364 383620 598715 614243 767448 173736 812856 864419 348955 402344 665714 827970 377326 966501 322577 410572 730984 214902 798529 688157 905792 956622 382598 114598 446157 860292 666053 418109 943852 68518 529944 733174 700577 365012 931483 423193 422964 840552 77337...

output:

4000060 322733 411324 226129 586872 371776 356247 383825 796752 639119 690681 621530 568140 491973 654228 593155 792757 647902 559906 557237 755574 624780 514407 732041 782870 587873 855872 524312 745692 551452 552357 829249 901946 461425 664654 632056 605448 862960 547265 547493 772026 704845 77040...

result:

wrong answer 1st lines differ - expected: '0 322733 411324 226129 586872 ...683 680267 587103 866107 506886', found: '4000060 322733 411324 226129 5...83 680267 587103 866107 506886 '