#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; int main() { int N1, C1, N2, limit, C2, N3, n, time = 0, mins, secs, ans; cin >> N1 >> C1 >> N2 >> limit >> C2 >> N3 >> n; for (int i = 0; i < n; i++) { scanf("%d:%d", &mins, &secs); ans = mins * 60 + secs; time += ans > 6 ? (ans + 59) / 60 : 0; } cout << "Basic: " << N1 + time*C1 << '\n' << "Combined: " << N2 + max(time - limit, 0) * C2 << '\n' << "Unlimited: " << N3; } Edited by author 25.09.2020 23:01 The cases when all times are less than 6 seconds are neglected. So the cost of each plan should be zero as all calling will be free but adding the basic plan to the cost leads to AC. You need to remember that string "no more than 6 sec". It means that you need ignoring all calls with 0 min and 0-6 sec including 6 sec. It's important for tests. //#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 calc () { string str; cin >> str; re (str[0] - '0') * 600 + (str[1] - '0') * 60 + stoi(str.substr(3, 2)); } int main() { int n1, n2, n3, c1, c2, t; cin >> n1 >> c1 >> n2 >> t >> c2 >> n3; int k, time; int ans = 0; cin >> k; while (k--) { time = calc(); if (time <= 6) continue; ans += (time + 59) / 60; } cout << "Basic: " << n1 + ans * c1 << endl; cout << "Combined: " << n2 + max(0, ans - t) * c2 << endl; cout << "Unlimited: " << n3 << endl; } plz can someone give the 4th test Try the case when total time is less than prepayed time in 'Combined' rate. I got WA#6, what is wrong? Send to me your solution - and I will try to find your mistake Edited by author 30.10.2009 22:44 I found your mistake. Test 0 1 0 20 0 300 1 25:00 right Answer: Basic: 25 Combined: 0 Unlimited: 300 Edited by author 30.10.2009 22:47 I gave this test and took right answer: Basic: 25 Combined: 0 Unlimited: 300 but again WA#6. Why? Help me, please can someone tell me the test case 4 for this question. kindly help I thihk Test4 is about "Combined" int GetCost() const { return abon + (totalMinut > minutLimit ? totalMinut - minutLimit : 0) * minutCost; } #include <iostream> #include <iomanip> int main() { unsigned short int p1, c1; unsigned short int p2, t, c2; unsigned short int p3; unsigned short int k; unsigned short int mm, ss; char s = ':'; std::cin >> p1 >> c1; std::cin >> p2 >> t >> c2; std::cin >> p3; std::cin >> k; for (int i=1; i<=k; i++) { std::cin >> mm >> s >> ss; if (mm>0 || ss>7) { if (ss!=0) mm++; p1 = p1 + mm*c1; if (mm>t) { mm-=t; t=0; } else { t-=mm; mm=0; } p2 = p2 + mm*c2; } } std::cout << setiosflags(std::ios::left) << std::setw(11) << "Basic: " << p1 << std::endl; std::cout << setiosflags(std::ios::left) << std::setw(11) << "Combined: " << p2 << std::endl; std::cout << setiosflags(std::ios::left) << std::setw(11) << "Unlimited: " << p3 << std::endl; return 0; } What's wrong? If your output format differs from the required output format (even by one space).....you will get WA. So be careful..... If you have WA 10, check your solution on this test: 0 0 0 0 1000 0 2 59:59 00:06 Right answer is: Basic: 0 Combined: 60000 Unlimited: 0 Edited by author 29.04.2012 16:14 Please,if any one can write all the test case's.... 0.001s and 128Kb :) ... for (i=0; i<num; i++) { scanf("%d:%d", &min, &sec); if (min==0 && sec<7) continue; if (sec != 0) min += 1; basic_price += min*basic_pm; min_all += min; } ... p.s.: HF & GL, it's very easy I wrote analogous solution by myself with a bit different cycles, but now it gets WA#6, not AC :( Can anyone gave me test 8 ? Edited by author 09.08.2011 16:37 #include <iostream> #include <stdio.h> using namespace std; int main(){ int b[2],c[3],u,n,min,sec,min_all; cin>>b[0]>>b[1]>>c[0]>>c[1]>>c[2]>>u>>n; for (int i=0; i < n; i++) { scanf("%d:%d", &min, &sec); if (min==0 && sec<7) continue; if (sec != 0) min += 1; b[0] += min*b[1]; min_all += min; } printf("Basic: %d\n",b[0]); printf("Combined: %d\n",c[0]); printf("Unlimited: %d\n",u); system("pause"); return 0; } WA1 ( had the same problem. decided - to put a space #include <stdio.h> int main() { int n1,c1,n2,t,c2,n3,k,i; scanf("%d %d",&n1,&c1); scanf("%d %d %d",&n2,&t,&c2); scanf("%d",&n3); scanf("%d",&k); int (*A)[2] = new int[k][2]; for( i=0; i<k; ++i ) { scanf("%d:%d",&A[i][0],&A[i][1]); } int basic = n1,combined = n2,unlimited = n3,bas=0,com=0;
for( i=0; i<k; ++i ) { if(A[i][0]!=0) { bas+=A[i][0]; com+=A[i][0]; } if( (A[i][0]==0 && A[i][1]>6) || (A[i][0]!=0 && A[i][1]!=0 ) ) { ++bas; ++com; } } if ( com>t ) { com-=t; com*=c2; } bas *= c1; basic += bas; combined += com;
printf("Basic: %d\n",basic); printf("Combined: %d\n",combined); printf("Unlimited: %d\n",unlimited); delete [] A; return 0; } Test: 135 1 220 10 1 300 5 00:05 00:10 00:59 05:00 01:01 Answer: Basic: 144 Combined: 220 Unlimited: 300 Combined in this test must be 221... because 00:10 gives 1 minute , 00:59 give 1 minute , 05:00 gives 5, 01:01 gives 2...or... 01:01 gives 1 minute or 2 minutes ?? 00:10 - 1 minute; 00:59 - 1 minute; 05:00 - 5 minutes; 01:01 - 2 minutes. All time is 9 minutes. In this test you are allowed to talk up to 10 minutes per month for free. You talked only 9. So you should pay only monthly fee - 220. Yes , thanks . I should write [ else com=0 ] after [ if(com > t){...} ] When sum<=T (which means that the limit is not exceeded ) you should write just a monthly fee N2. In C++ : if (sum<=T) cout<<"Combined: "<<N2<<endl; Good Luck Friends!!! can somebody please tell me how format of output should be?? thanks.. put spaces at the three lines of the output alex ;) I figured it out long back..thanks anyway the best way is to copy part of text from the web. It really works :) Edited by author 21.02.2008 04:09 Edited by author 21.02.2008 04:09 :) thank you Edited by author 05.11.2007 17:26 ok? Edited by author 05.11.2007 18:09 for this i have WA1 plzz help me :(( "The number of minutes in a call is rounded up (i.e., a call with duration of 8:10 is charged the same as a call with duration of 9:00)". So the total time in the 1'st example is 1+10+7+2=20 minutes (the call that lasts 00:05 is ignored). Thank you very much... :D thank you... Now I get WA4 :((((((( can you look on my code(I will delete it otherwise): #include <stdio.h> #include <math.h> long n1, c1, n2, t, c2, n3, nr, i, mnt, p1; char s[16]; int main() { #ifndef ONLINE_JUDGE freopen("1576.in", "r", stdin); freopen("1576.out", "w", stdout); #endif scanf("%ld%ld", &n1, &c1); scanf("%ld%ld%ld", &n2, &t, &c2); scanf("%ld", &n3); scanf("%ld", &nr); for (i = 1;i <= nr; ++i) { scanf("%s", s); mnt =(((long)s[0] - '0') * 10 + ((long)s[1] - '0')) * 60 + ((long)s[3] - '0') * 10 + ((long)s[4] - '0'); if (mnt > 6) { if (mnt % 60 != 0) { p1 = p1 + mnt / 60 + 1; } else { p1 = p1 + mnt / 60; } } } printf("Basic: %ld\n", n1 + p1 * c1); printf("Combined: %ld\n", (n2 + p1 - t) * c2); printf("Unlimited: %ld\n", n3); return 0; } Edited by author 06.11.2007 22:06 Edited by author 06.11.2007 22:07 help me please. Why I've WA 1 ? I use spaces in output format and my answers are true((((( var i,k,n1,c1,p,n2,t,c2,n3:word; sum,sek:longword; code:integer; s:string; begin //assign(input,'input.txt'); // assign(output,'ouput.txt'); readln(n1,c1); readln(n2,t,c2); readln(n3); readln(k); for i:=1 to k do begin readln(s); val(s,p,code); val(copy(s,4,2),sek,code); if (p=0) and (sek<=6) then sum:=sum else begin sum:=sum+p; if sek>0 then sum:=sum+1; end; end; writeln('Basic: ',c1*sum+n1); if t>=sum then sek:=n2 else sek:=n2+(sum-t)*c2; writeln('Combined: ',sek); writeln('Unlimited: ',n3); end. maybe more spaces, like this: writeln('Basic:.....', writeln('Combined:..', writeln('Unlimited:.', point = space ;) Edited by author 03.11.2007 03:11 please help me, why I've WA 1 ???? Edited by author 14.10.2007 22:49 Edited by author 14.10.2007 22:49 Maybe, in cause of wrong output format. Use spaces. |
|