結果
問題 | No.335 門松宝くじ |
ユーザー | LayCurse |
提出日時 | 2016-01-16 00:05:59 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 3,345 bytes |
コンパイル時間 | 1,349 ms |
コンパイル使用メモリ | 162,568 KB |
実行使用メモリ | 10,748 KB |
最終ジャッジ日時 | 2024-09-19 19:38:59 |
合計ジャッジ時間 | 2,238 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,624 KB |
testcase_01 | AC | 2 ms
7,492 KB |
testcase_02 | AC | 2 ms
7,496 KB |
testcase_03 | AC | 2 ms
7,496 KB |
testcase_04 | AC | 1 ms
7,624 KB |
testcase_05 | AC | 5 ms
9,676 KB |
testcase_06 | AC | 7 ms
10,376 KB |
testcase_07 | AC | 10 ms
10,392 KB |
testcase_08 | AC | 7 ms
10,640 KB |
testcase_09 | AC | 13 ms
10,748 KB |
testcase_10 | AC | 14 ms
10,452 KB |
testcase_11 | AC | 13 ms
10,252 KB |
testcase_12 | AC | 12 ms
9,860 KB |
testcase_13 | AC | 12 ms
9,772 KB |
コンパイルメッセージ
main.cpp: In function ‘void reader(double*)’: main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | void reader(double *x){scanf("%lf",x);} | ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define mygc(c) (c)=getchar_unlocked() #define mypc(c) putchar_unlocked(c) #define ll long long #define ull unsigned ll void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(double *x){scanf("%lf",x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);} template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);} template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(double x, char c){printf("%.15f",x);mypc(c);} void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template<class T> void writerLn(T x){writer(x,'\n');} template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');} template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');} template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');} char memarr[17000000]; void *mem = memarr; #define MD 1000000007 int N, M; int A[3][888]; int g[3]; int mx[888][888], mn[888][888]; int main(){ int i, j, k; int x, y, z, t; reader(&N,&M); rep(i,M) rep(j,N) reader(A[i]+j), A[i][j]--; rep(k,M){ rep(i,N){ mn[i][i] = mx[i][i] = A[k][i]; REP(j,i+1,N){ mn[i][j] = min(mn[i][j-1], A[k][j]); mx[i][j] = max(mx[i][j-1], A[k][j]); } } rep(x,N) REP(y,x+1,N){ z = -1; if(y!=x+1){ t = mx[x+1][y-1]; if(t > max(A[k][x],A[k][y])) z = max(z,t); t = mn[x+1][y-1]; if(t < min(A[k][x],A[k][y])) z = max(z,max(A[k][x],A[k][y])); } if(A[k][x] < A[k][y]){ if(x-1>=0){ t = mx[0][x-1]; if(t > A[k][x]) z = max(z,max(A[k][y],t)); } if(y+1<N){ t = mn[y+1][N-1]; if(t < A[k][y]) z = max(z,A[k][y]); } } else { if(x-1>=0){ t = mn[0][x-1]; if(t < A[k][x]) z = max(z,A[k][x]); } if(y+1<N){ t = mx[y+1][N-1]; if(t > A[k][y]) z = max(z,max(A[k][x],t)); } } g[k] += z+1; } } rep(i,M){ rep(j,M) if(g[i] < g[j]) break; if(j==M){ writerLn(i); return 0; } } return 0; }