|
|
back to boardWA3 What's wrong in my program? I can't find mistake. Anybody knows it? #include<fstream> #include<iostream> #include<cstdio> using namespace std; long n, m; __int64 x, y = 0, n1; int main (){ cin >> n >> m; n1 = 3*n; for (int i = 0; i < m; ++i){ cin >> x; y+=x; if (y >= n1){ cout << "Free after " << i+1 << " times."; return 0; } } cout << "Team.GOV!"; return 0; } Re: WA3 i got wa #3.why ??? Re: WA3 I have the same problem. Algorithm: //----------------------------------------------- #include<stdio.h> void main(void){ int exit,goes,i,sum=0; int sums[3000]; bool free=false; scanf("%d %d",&exit,&goes); exit*=3; for(i=0;i<goes;i++) scanf("%d",&sums[i]);
for(i=0;i<goes;i++) { sum+=sums[i]; if(sum>=exit) {free=true; break;} } if(free==true) printf("Free after %d times.",i+1); else printf("Team.GOV!"); } //---------------------------------------------- Wrong answer, test No.3 explanation your mistakes are very simple - guy's spent money should overwhelm (not equal!) n. |
|
|