結果
問題 |
No.335 門松宝くじ
|
ユーザー |
![]() |
提出日時 | 2016-01-15 23:02:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,485 bytes |
コンパイル時間 | 1,241 ms |
コンパイル使用メモリ | 160,572 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-19 19:25:10 |
合計ジャッジ時間 | 14,705 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 5 WA * 5 |
コンパイルメッセージ
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])); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#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; }