I try to solve this problem 2B in Java. My class was compiled in Eclipse but when I submited it, Codeforces's verdict is runtime error. I have read other's code in Java but I can't find out the problem. Why did it happen? Here is my code
# | User | Rating |
---|---|---|
1 | ecnerwala | 3649 |
2 | Benq | 3581 |
3 | orzdevinwang | 3570 |
4 | Geothermal | 3569 |
4 | cnnfls_csy | 3569 |
6 | tourist | 3565 |
7 | maroonrk | 3531 |
8 | Radewoosh | 3521 |
9 | Um_nik | 3482 |
10 | jiangly | 3468 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 162 |
4 | TheScrasse | 159 |
5 | nor | 158 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 151 |
8 | SecondThread | 147 |
9 | orz | 146 |
10 | pajenegod | 145 |
I try to solve this problem 2B in Java. My class was compiled in Eclipse but when I submited it, Codeforces's verdict is runtime error. I have read other's code in Java but I can't find out the problem. Why did it happen? Here is my code
I am wondering if there is a way to implement 466Cthat use binary search? Can anyone give me an answer.
Problem 457A Test 8 only contains 1 line in input. Is this a wrong test case?
Hello every one.I am newbie on Codeforces. I am trying to solve this problem on Codeforces link. They suggest me using dp and greedy. This is my code and it had wrong answer on test 11. Can any one help me. Thank you so much. ~~~~~
using namespace std;
int N; int X; int c[100]; long a[100]; long l[MAX];
void input(){ ifstream fin("input.txt");
fin>>N;
fin>>X;
for(int i = 0; i < N; i++) fin>>c[i];
fin.close();
}
void output(int n){ ofstream fout("output.txt"); fout<<n; fout.close(); }
void solution(){
long max;
long maxtong;
long i;
long j;
long sum;
l[0] = 0;
maxtong = 0;
for(i = 1; i <= MAX -1 ; i++) l[i] = -1;
for(i = 0; i < N; i++){
max = maxtong;
for(j = maxtong; j >= 0; j--){
if( j + a[i] > X) continue;
if(l[j] != -1 && l[j] + 1 > l[j + a[i]]) {
l[j + a[i]] = l[j] + 1;
if( max < j + a[i]) max = j + a[i];
}
}
maxtong = max;
}
}
int main(){ input(); for(int i = 0; i < N; i++) a[i] = c[i] * (N — i);
solution();
for(long i = X; i >= 0; i--) if(l[i] != -1) {
output(l[i]);
exit(0);
}
} ~~~~~
Name |
---|