Last active
August 29, 2015 14:12
-
-
Save note35/09d8882523ad2d1689e9 to your computer and use it in GitHub Desktop.
Revisions
-
note35 revised this gist
Jan 4, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,7 @@ int main(void) tmp = ans; for (it=v.begin(); it!=v.end(); it++) { offset = *(it+range) - *it; if (tmp + offset > ans) ans = tmp + offset; tmp = tmp + offset; -
note35 revised this gist
Jan 4, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,15 +27,15 @@ int main(void) cin >> input; v.push_back (input); if (i<range) ans += input; } v.push_back (-1); tmp = ans; for (it=v.begin(); it!=v.end(); it++) { offset = -*it + *(it+range); if (tmp + offset > ans) ans = tmp + offset; tmp = tmp + offset; if (*(it+range) == -1) -
note35 created this gist
Jan 4, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ /* https://www.ptt.cc/bbs/C_Chat/M.1417696853.A.E8F.html https://paiza.jp/poh/enkoi 提出言語:C++ 得点:100 点 結果: テストケース1:success 0.01秒 テストケース2:success 0.01秒 テストケース3:success 0.01秒 */ #include <iostream> using namespace std; int main(void) { int input_n, input, i, ans=0; cin >> input_n; for (i=0; i<input_n; i++) { cin >> input; ans += input; } cout << ans << endl; return 0; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ /* https://www.ptt.cc/bbs/C_Chat/M.1417696853.A.E8F.html https://paiza.jp/poh/enkoi 提出言語:C++ 得点:100 点 結果: テストケース1:success 0.01秒 テストケース2:success 0.01秒 テストケース3:success 0.01秒 */ #include <iostream> using namespace std; int main(void) { int input_n, input1, input2, input3, i, ans=0; cin >> input_n; for (i=0; i<input_n; i++) { cin >> input1 >> input2 >> input3; if ((input1 - input2) > 0) ans = ans + (input1 - input2)*input3; } cout << ans << endl; return 0; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ /* https://www.ptt.cc/bbs/C_Chat/M.1417696853.A.E8F.html https://paiza.jp/poh/enkoi 提出言語:C++ 得点:100 点 結果: テストケース1:success 0.01秒 テストケース2:success 0.01秒 テストケース3:success 0.01秒 テストケース4:success 0.22秒 テストケース5:success 0.22秒 */ #include <iostream> #include <vector> using namespace std; int main(void) { int range, input_n; int i, input, ans=0, tmp=0, offset; vector <int> v; vector <int>::iterator it; cin >> range >> input_n; for (i=0; i<input_n; i++) { cin >> input; v.push_back (input); if (i<range) ans+=input; } v.push_back(-1); tmp = ans; for (it=v.begin(); it!=v.end(); it++) { offset = -*it+*(it+range); if (tmp+offset > ans) ans = tmp + offset; tmp = tmp + offset; if (*(it+range) == -1) break; } cout << ans << endl; return 0; }