結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2014-11-26 00:12:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 683 bytes |
| コンパイル時間 | 340 ms |
| コンパイル使用メモリ | 51,764 KB |
| 最終ジャッジ日時 | 2024-11-14 18:55:34 |
| 合計ジャッジ時間 | 874 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:9: error: ‘vector’ was not declared in this scope
9 | vector<int> a(n);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:9:16: error: expected primary-expression before ‘int’
9 | vector<int> a(n);
| ^~~
main.cpp:11:21: error: ‘a’ was not declared in this scope
11 | for(int& v: a) {
| ^
main.cpp:18:20: error: expected primary-expression before ‘int’
18 | vector<int> b(i);
| ^~~
main.cpp:19:37: error: ‘b’ was not declared in this scope
19 | for(int j=0;j<=i/2;++j) b[j]=b[i-1-j]=j+1;
| ^
main.cpp:20:36: error: ‘b’ was not declared in this scope
20 | int t=accumulate(begin(b), end(b), 0);;
| ^
main.cpp:20:19: error: ‘accumulate’ was not declared in this scope
20 | int t=accumulate(begin(b), end(b), 0);;
| ^~~~~~~~~~
main.cpp:24:45: error: ‘a’ was not declared in this scope
24 | for(int j=0;j<min(n,i);++j) if (a[j]>b[j]) x+=a[j]-b[j];
| ^
main.cpp:25:37: error: ‘a’ was not declared in this scope
25 | for(int j=i;j<n;++j) x+=a[j];
| ^
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
while (cin>>n) {
vector<int> a(n);
int s=0;
for(int& v: a) {
cin>>v;
s+=v;
}
int res=1<<29;
for(int i=1;i<=200;i+=2) {
vector<int> b(i);
for(int j=0;j<=i/2;++j) b[j]=b[i-1-j]=j+1;
int t=accumulate(begin(b), end(b), 0);;
if (t>s) break;
int x=0;
for(int j=0;j<min(n,i);++j) if (a[j]>b[j]) x+=a[j]-b[j];
for(int j=i;j<n;++j) x+=a[j];
res=min(res, x);
}
cout<<res<<endl;
}
}
hogeover30