結果

問題 No.335 門松宝くじ
ユーザー rickythetarickytheta
提出日時 2016-01-15 23:02:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,485 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 161,236 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-19 23:31:03
合計ジャッジ時間 14,726 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 319 ms
4,372 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1,973 ms
4,348 KB
testcase_10 TLE -
testcase_11 AC 1,986 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:21: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=]
   33 |     REP(i,n)scanf("%d",&(lot[i]));
      |                    ~^  ~~~~~~~~~
      |                     |  |
      |                     |  ll* {aka long long int*}
      |                     int*
      |                    %lld
main.cpp:24:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |   scanf("%d%d",&n,&m);
      |   ~~~~~^~~~~~~~~~~~~~
main.cpp:33:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |     REP(i,n)scanf("%d",&(lot[i]));
      |             ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  // length : n
  // alternatives : m

  // 2個選ぶ→O(n^2)
  ll mxval = -1;
  ll ans = -1;
  REP(x,m){
    ll lot[n];
    REP(i,n)scanf("%d",&(lot[i]));
    ll res = 0;
    REP(i,n)REP(j,i){
      // ~~~ j ~~~~ i ~~~~
      ll left = lot[j];
      ll right = lot[i];
      ll mx = 0;
      bool less = left<right;
      FOR(k,0,j){
        if(less && lot[k]>left) mx = max(mx,max(right,lot[k]));
        else if(!less && lot[k]<left) mx = max(mx,left);
      }
      FOR(k,j+1,i){
        if(lot[k]>left && lot[k]>right) mx = max(mx,lot[k]);
        else if(lot[k]<left && lot[k]<right) mx = max(mx,less?right:left);
      }
      FOR(k,i+1,n){
        if(less && lot[k]<right) mx = max(mx,right);
        else if(!less && lot[k]>right) mx = max(mx,max(left,lot[k]));
      }
      res += mx;
    }
    if(res > mxval){
      mxval = res;
      ans = x;
    }
  }
  cout << ans << endl;
  return 0;
}
0