/* :::: author:@DEANNOS at CODEFORCES 2022 :::: */ #include <bits/stdc++.h> //using policy based stl #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> using namespace std; #define endl "\n" #define mod 1000000007 #define ll long long #define ld long double #define vi vector<int> #define vll vector<ll> #define pll pair<ll, ll> #define pii pair<int, int> #define ld long double #define ff first #define ss second #define vs vector<string> #define vpll vector<pll> #define vb vector<bool> #define pb push_back #define bg begin() #define mp make_pair #define ed end() #define gi greater<int> () #define srt(v) (sort(all()) #define all(c) (c).begin(), (c).end() #define sz(x) (int)(x).size() #define fo(i,n) for(ll i=0;i<n;i++) #define Fo(i,k,n) for(ll i=k;i<n;i++) const int INF = 1000000000; const int MAX_N = 2e5; /* int fastpower(int x, int y, int mod) { int res = 1; x = x % mod; if (x == 0) { return 0; } while (y > 0) { if (y & 1) { res = (res*x) % mod; } y = y>>1; x = (x*x) % mod; } return res; } */ /* int GCD(int a,int b) { while(b!=0) { int rem=a%b; a=b; b=rem; } return a; } */ ll integer(ll a) { return a >= 0 ? a : -a; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; ll ans1 = 1, ans2 = 2, mx = 0; ll a; cin >> a; for (int i = 1; i < n; i++) { ll b; cin >> b; if (integr(a - b) > mx) { mx = integer(a - b); ans1 = i; ans2 = i + 1; } a = b; } cout << ans1 << ans2 << endl; return 0; } 1) Maybe, you are reading long long variable with this command : scanf("%d",&arr[i]); It is not right. You should do, for example, it with next command scanf("%I64d",&arr[i]); 2) Maybe, you were confused by statement. You have to choose such two points so line that passing through this points has maximal absolute value of inclination, not just inclination. 3) Maybe, you are doing something like this : for ( int i = 1 ; i <= n ; ++i ) { long long d = abs2(arr[i+1] - arr[i]); if ( d > x ) { x = d; m1 = i; } } There is a mistake in first line. Right way is for ( int i = 1 ; i < n ; ++i ) { It was my biggest mistake, because the problem itself is so simple. Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! Thanks a lot! The definition of inclination is ambiguous in the problem statement. Thanks a lot! I have ignored "absolute value" too. Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! Thannnnnnnnnnnnnnnnnk youuuuuuuuuuuuuu verrrrrrrrrrrrry mucccccccccccccch! [code deleted] Edited by moderator 02.01.2020 18:17 cout<<"enter a number for the lines "<<endl; Surely that is wrong In C++, you'd better use "long long" instead of "long". What is test 3??? Help me!!! Please!!! if 'a' and 'b' are both longint,abs(a-b) can be __int64. AC) Edited by author 21.07.2012 01:25 #include<iostream> #include<cstdlib> #include<cstdio> #include<cmath> long a[100000]; long b[100000]; long c[100000]; int d[100000]; using namespace std; int main(){ int n; int max; cin>>n; int i; for (i=0; i<n; i++){ cin>>a[i]; d[i]=1; } for (i=0; i<n-1; i++){ float r=1+(a[i+1]-a[i])*(a[i+1]-a[i]); c[i]=sqrt(r);
} for (i=0; i<n-2; i++){ if ((a[i]-a[i+1])==(a[i+1]-a[i+2])){ c[i+1]+=c[i]; d[i+1]=d[i]+1; //cout<<d[i]<<" "; } } max=c[0]; int t=0; for (i=0; i<n-1; i++){ if (max<c[i]) { max=c[i]; t=i; } } // cout<<d[0]<<" "<<d[1]<<" "<<d[2]<<" "<<d[3]<<" "; cout<<t+2-d[t]<<" "<<t+2; system("pause"); } Why WA2? May be, someone had same problem? My program here: [code deleted] Edited by author 28.03.2005 22:30 Edited by moderator 02.01.2020 18:24 Yahooo!!! I have surmised! "inclination" - it is absolute value, without sign! But author should mentioned it in the task, in my opinion. Yes,you're right! Thank you very much.! The author should mentioned.It is a big problem.I think. yeah,I think it is important. This code gets WA on test 2: [code deleted] & this gets AC: [code deleted] :) Edited by moderator 02.01.2020 18:26 Try to use scanf("%I64d", &tab[i]); Oh! It's like in dev :) thx for info. . The operating system may be windows, not linux, but why it return WA instead of CE? Edited by author 27.07.2009 20:46 Cause your solution is wrong. I also have this weird problem. Long long variables got WA@2, and if changed to long double everything is AC... Just change longint into int64. Oh,my god! Don't the author say all values are longint? C99 7.20.6.1: long long int llabs(long long int j); but when I submit my code with use of llabs, I got CE. fmax(double,double) also doesn't work well LLONG_MAX will get CE too. If you use long long,ABS does not work,as this got WA on #2 [code deleted] But this got AC! [code deleted] Edited by moderator 02.01.2020 18:27 This solution isn't good at all.May be there will be points a[0] and a[n] that maxn=abs2(a[0]-a[n]).Your program don't work this time. remeber that "Each value of the function is longint (signed long in C++)",so if value[i]=-maxlongint and value[j]=maxlongint then abs(value[i]-value[j])>maxlongint so DO use long long or int64.(i got WA just because of it for 10 times) so do i i got wa for nearly ten times Edited by author 19.07.2009 19:24 input 5 1 1 1 1 1 correct answer 1 2 This test I'm right 。But I WA 2 again I WAed many times for this........ RPWT..................-_-||| 囧。。。 Thanks a lot, I've sent my solution 8 times before reading this post, and of course they have failed. i used long in java and got AC 1、The value of the function can be a real. Use extended to solve the problem and you will get AC. 2、The progblem says that the line is above the points between the begining and the end of the line,not 'all of the points'. May the force be with you. |
|