Last active
August 29, 2015 14:12
-
-
Save note35/09d8882523ad2d1689e9 to your computer and use it in GitHub Desktop.
enkoi
This file contains 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 characters
/* | |
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 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 characters
/* | |
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 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 characters
/* | |
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+range) - *it; | |
if (tmp + offset > ans) | |
ans = tmp + offset; | |
tmp = tmp + offset; | |
if (*(it+range) == -1) | |
break; | |
} | |
cout << ans << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment