結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
![]() |
提出日時 | 2015-02-17 23:58:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 236 ms / 5,000 ms |
コード長 | 1,484 bytes |
コンパイル時間 | 1,057 ms |
コンパイル使用メモリ | 90,332 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 22:29:05 |
合計ジャッジ時間 | 4,004 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:42:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | FOR(i,N) scanf("%d",&A[i]); | ~~~~~^~~~~~~~~~~~ main.cpp:43:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | FOR(i,N) scanf("%d",&B[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<iostream> #include<sstream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> #include<vector> #include<cmath> #include<set> #include<map> #include<stack> #include<queue> #include<numeric> #include<functional> #include<complex> using namespace std; #define BET(a,b,c) ((a)<=(b)&&(b)<(c)) #define FOR(i,n) for(int i=0,i##_end=(int(n));i<i##_end;i++) #define SZ(x) (int)(x.size()) #define ALL(x) (x).begin(),(x).end() #define MP make_pair #define FOR_EACH(it,v) for(__typeof(v.begin()) it=v.begin(),it_end=v.end() ; it != it_end ; it++) typedef vector<int> VI; typedef vector<VI> VVI; struct monster{ int index; int level; int attack; friend bool operator<(const monster&m1, const monster&m2){ if(m1.level != m2.level) return m1.level > m2.level; return m1.attack > m2.attack; } }; int main() { int N; cin>>N; VI A(N), B(N); FOR(i,N) scanf("%d",&A[i]); FOR(i,N) scanf("%d",&B[i]); int ans = 1<<28; FOR(start,N){ priority_queue<monster> qu; FOR(i,N) { qu.push((monster){ i, A[i], 0 }); } int maxAttack = 0; FOR(i,N){ int targetLevel = B[(start + i) % N]; monster m = qu.top(); qu.pop(); m.level += targetLevel / 2; m.attack++; maxAttack = max(maxAttack, m.attack); qu.push(m); } ans = min(ans, maxAttack); } cout<<ans<<endl; return 0; }