Remember: maximum accuracy can not be more than 10 in minus the secong degree. Запомните: максимальная точность числа не больше 10 в -2 степени. What is the test #11?Give,please...... I believe test 11 is a test in which Ivan saves himself after the last restaurant. Example: 2000 3 2000 2000 2001 Answer: Free after 3 times. Edited by author 09.01.2011 19:55 Thank you, this is the reason of my WA11. //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; int main() { ll n, m, x; cin >> n >> m; n *= 3; fo(i, m) { cin >> x; n -= x; if (n < 0) { cout << "Free after " << i + 1 << " times.\n"; re 0; } } cout << "Team.GOV!\n"; } #include <iostream> #include <cmath> #include <iomanip> #include <vector> #include<algorithm> using namespace std; int main() { long long a, c, d, min, max, n, x;
long double b, e, sum; cin >> a >> n; sum = 0; d = 0; vector<long long> z(n); for (long long i = 0; i < n ; ++i) { cin >> z[i]; } for (long long i = 0; i < n; ++i) {
b = z[i] / 3; sum = sum + b; d = d + 1; if (a < sum) { break; }
} if (a > sum) { cout << "Team.GOV!" << endl; } else { cout << "Free after " << d << " times." << endl; } return 0; } Do not use "n/3" or "n div 3" or "input div 3" or "input/3". Do not use any division. while input n, n:=n*3 ; and then you won't have to divide at 3 every input; Sorry for bad english.If any questions please ask. #include "stdio.h" #include "stdlib.h" #include<string.h> int main() { long int m,n,sum=0,a[3001]; scanf("%ld %ld",&n,&m); for(int i=1;i<=m;i++) { scanf("%d",&a[i]); } n=n*3; for(int i=1;i<=m;i++) { sum+=a[i]; if(sum>=n) { printf("Free after %d times.",i); return 0; } } printf("Team.GOV!"); } the same question YES (Just got AC) I don't know how partisan can get AC In fact, sum(cost1+cost2+...) should be strongly greater than n*3 YES! STRONGLY GREATER ONLY!!! If you'll use >=, you get WA#3 or smth like that >_< I wish them publish more EXACT problem situations... >_> It says here: "the money Vadim had paid for him exceeded n rubles" Since I automatically just thought it had to be only greater or equal to N (because that sounds way more logical), I got WA at test #3 and I had no idea why. This is a programming problem, not a reading one - I think there should be more emphasis on the difficulty of *making the solution*, not on understanding the text and looking for small details hidden between hundreds of words. I know the task is very easy, but that doesn't mean making the statement look more complicated will balance things out. Of course, I wouldn't mind a long statement, as long as there is a recap of everything at its end. For example, something like "For a given integer N(1<=N<=2*10^9), integer M(0<=M<=3000) and M integers a[1,2...M] (1<=a[i]<=2*10^6 inclusive), print the index i for which (a[1]+a[2]+...+a[i])/3 > N. If there is no such index, print "Team.GOV!"" My code #include <stdio.h> int main() { long long n, s; int m; scanf("%lld%d",&n,&m); n*=(long long)3; s=0; for(int i=0; i<m; i++) { int t; scanf("%d",&t); s+=t; if(s>n) { printf("Free after %d times.",i+1); return 0; } } printf("Team.GOV!"); return 0; } Works fine on my machine under Linux (g++ 4.8.2). On the OnlineJudge I get WA1 on g++ and AC on VC++ 2010. I think something is wrong. %lld doesn't work for MinGW GCC. Use %I64d It's strange but for m=0 correct answer is "Team.GOV!". (I think that the correct answer should be "Free after 0 times." I have tried double but it does not work can anybody tell me why ??? If you have WA, you must use long long(or int64 in Pascal).And don't use sum/3>n,use sum>n*3.After that you have AC. По русски. Не используйте типы int(или integer). Используйте типы int64(или long long). При сравнение не сумма/3>выхода,а сумма>выход*3. Желаю всем красивых AC! P.S. Sorry for bad English. thx Well, this method guarantee you simple AC solution, but to decrease time and get finally 0.015 secs you should come back to 32-bit ints. Keep somewhere the undivided part (the remainder) and try to eliminate it with each new value read. At the time you compare the sum to N (or the remains of N to zero) you should not forget the remainder. Write something as "if(n<0||!n&&r)" in the place of condition. Thanks helped very much!!!! What is wrong with this test? use s > 3*n instead of s / 3 > n whats wrong with this program? Got AC using __int64 instead of long long. Anybody willing to explain why? Whats the difference between __int64 and long long? Edited by author 28.02.2009 15:59 because s can be greater than max(long long). Use int64 instead. But the maximum value of s can be 3000*2*10^6 which is well within the range of long long? I use int64 and s>n*3 but have WA10, what's wrong with this program? me too maybe you should use qword instead of int64 as i did? do not forget to make them both qword and multiply first by three rather than dividing another one. u can use unsigned long long and get AC But if i use it i have wa 10 Wrong Answer 2 in my pascal code and in this /\ /\ /\ C code use long... something biger than int is needed. I have wrong answer in my 7th testcase! can you tell me Why? bcs of wrong data types u need 8-byte data type 4-byte are useless my program crashed even on 3rd Edited by author 06.10.2011 03:33 Solved... I forgot that m can be Zero! To pass this test you should use int64 or long long.Good luck! I think you should use the test like 1000 5 1000 1000 1000 1000 1000 (answer 4) to pass it what's wrong? program t1688; var h:array [1..3000] of int64; a,p:int64; n,m:int64; b,i,j:longint; begin readln(a,b); for i:=1 to b do readln(h[i]); for i:=1 to b-1 do for j:=b downto i+1 do begin if h[i]>h[j] then begin p:=h[i]; h[i]:=h[j]; h[j]:=p; end; end; for i:=1 to b do begin m:=m+h[i]; if a*3<m then inc(n); end; if n=0 then writeln('Team.GOV!') else writeln('Free after ',b-n,' times.'); end. Edited by author 16.04.2010 11:37 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; } 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 your mistakes are very simple - guy's spent money should overwhelm (not equal!) n. People, __int64 not needed! I quickened my program from 0.31 to 0.15 when returned __int64 to int (if that was not a fluctuation). Listen here. During one meal Ivan can save about 2*10^6/3 ~ 666667 rub. This is maximum increment of saved money. So at maximum the saved sum will be 2*10^9 + 666667, which is much less than 2^31-1. My trouble (and most likely yours too) was connected with that i checked if saved sum is strictly greater than n fogetting of the fractional part. This is the case when ( integer part of saved money == n) BUT ( integer part == n AND fractional part > 0) u can use double but beware during comparison of double numbers since c language behaves abnormally while comparing floating point numbers. otherwise problem is as easy as it seems. if you are getting WA11 then read problem statement properly again and again. You can solve this problem using only int, not even int64. Edited by author 13.05.2009 23:29 Edited by author 13.05.2009 23:29 |
|