提出 #19473073


ソースコード 拡げる

#include<bits/stdc++.h>
#define N 200010
using namespace std;
int n;
int a[N],b[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	int nowa=1,nowb=1;
	printf("%lld\n",(long long)a[1]*b[1]);
	int last=1;
	for(int i=2;i<=n;i++)
	{
		if(b[i]>=b[nowb])nowb=i;
		else if((long long)a[last]*b[i]>=(long long)a[nowa]*b[nowb])nowb=i;
		if(last<=nowb)nowa=last;
		if(a[i]>a[nowa])
		{
			if((long long)a[i]*b[i]>=(long long)a[nowa]*b[nowb])nowa=i,nowb=i;
			if((long long)a[last]*b[i]>=(long long)a[nowa]*b[nowb])nowa=last,nowb=i;
		}
		if(last<=nowb)nowa=last;
		if(a[last]<a[i])last=i;
		if(last<=nowb)nowa=last;
		printf("%lld\n",(long long)a[nowa]*b[nowb]);
	}
	return 0;
}

提出情報

提出日時
問題 A - Two Sequences 2
ユーザ pengym
言語 C++ (GCC 9.2.1)
得点 300
コード長 765 Byte
結果 AC
実行時間 79 ms
メモリ 5812 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:8:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    8 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
./Main.cpp:9:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    9 |  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
      |                        ~~~~~^~~~~~~~~~~~
./Main.cpp:10:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   10 |  for(int i=1;i<=n;i++) scanf("%d",&b[i]);
      |                        ~~~~~^~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 18
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 66 ms 5276 KiB
random_02.txt AC 77 ms 5812 KiB
random_03.txt AC 71 ms 5796 KiB
random_04.txt AC 79 ms 5776 KiB
random_05.txt AC 29 ms 4180 KiB
random_06.txt AC 8 ms 3596 KiB
random_07.txt AC 15 ms 3832 KiB
random_08.txt AC 23 ms 4044 KiB
random_09.txt AC 37 ms 4300 KiB
random_10.txt AC 23 ms 3972 KiB
random_11.txt AC 29 ms 4140 KiB
random_12.txt AC 11 ms 3732 KiB
random_13.txt AC 2 ms 3672 KiB
random_14.txt AC 4 ms 3728 KiB
random_15.txt AC 2 ms 3628 KiB
random_16.txt AC 2 ms 3672 KiB
sample_01.txt AC 2 ms 3720 KiB
sample_02.txt AC 1 ms 3632 KiB