結果

問題 No.871 かえるのうた
ユーザー tarattata1tarattata1
提出日時 2019-08-31 00:50:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,452 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 74,308 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 23:14:51
合計ジャッジ時間 4,233 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 4 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 RE -
testcase_36 AC 29 ms
5,608 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 19 ms
5,376 KB
testcase_41 WA -
testcase_42 AC 18 ms
5,496 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:30:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |     scanf("%d%d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~
main.cpp:35:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   35 |         scanf("%lld", &x[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
main.cpp:38:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |         scanf("%lld", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;




int main(int argc, char* argv[])
{
    int n,k;
    scanf("%d%d", &n, &k);

    vector<ll> x(n),a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%lld", &x[i]);
    }
    for(i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }
    
    vector<ll> maxval, minval, xval, xval2;
    for(i=k-1; i<n; i++) {
        if(i==k-1) { maxval.push_back(x[i]+a[i]); xval.push_back(0); }
        else       { maxval.push_back(MAX(maxval.back(),x[i]+a[i])); xval.push_back(x[i]-x[k-1]); }
    }
    for(i=k-1; i>=0; i--) {
        if(i==k-1) { minval.push_back(a[i]-x[i]); xval2.push_back(0); }
        else       { minval.push_back(MAX(minval.back(),a[i]-x[i])); xval2.push_back(x[k-1]-x[i]); }
    }

    int mini=0, maxi=0;
    for(i=0; i<n; i++) {
        maxi=lower_bound(xval.begin(), xval.end(), maxval[mini]+1)-xval.begin()-1;
        mini=lower_bound(xval2.begin(), xval2.end(), minval[mini]+1)-xval2.begin()-1;
    }
    printf("%d\n", maxi+mini+1);

    return 0;
}
0