Submission #781986

#TimeUsernameProblemLanguageResultExecution timeMemory
781986kebineNaboj (COCI22_naboj)C++17
0 / 110
190 ms23360 KiB
#include<bits/stdc++.h> #define ll long long #define fi first #define sec second #define pb push_back #define pqueue priority_queue #define int long long #define pii pair<int,int> #define supercepat ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); using namespace std; int tc,n,k,c,p; int dis[1005][1005]; int a[200005]; int b[200005]; bool sub3=1; void tes3(){ int maxjar,temp3; for(int i=1;i<=n;i++){ maxjar=max(abs(n-i)+1,abs(i-1)+1); int l=1,r=maxjar,mid,temp3=1; while(l<=r){ mid=(l+r)/2; if((mid-1)*c<=k){ l=mid+1; temp3=mid; } else r=mid-1; } cout<<temp3<<" "<<k-((temp3-1)*c)<<endl; } } main(){ supercepat; cin>>n>>k>>c>>p; for(int i=1;i<=n;i++){ cin>>a[i]; if(a[i]>0) sub3=0; } for(int i=1;i<=n;i++){ cin>>b[i]; if(b[i]>0) sub3=0; } if(sub3){ tes3(); } else{ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i!=j){ dis[i][j]=abs(i-j)*c; } } } for(int i=1;i<=n;i++){ pair<int,int> ans; ans.fi=0; ans.sec=0; int temp=k-a[i]; // cout<<"temp "<<temp<<endl; int cost; for(int j=1;j<=n;j++){ cost=dis[i][j]+b[j]; if(cost<=temp){ if(abs(i-j)+1>ans.fi){ ans.fi=abs(i-j)+1; ans.sec=temp-(dis[i][j]+b[j]); } else if(abs(i-j)+1==ans.fi){ ans.sec=max(ans.sec,temp-(dis[i][j]+b[j])); } } } if(ans.fi==0&&ans.sec==0) cout<<0<<" "<<k<<endl; else cout<<ans.fi<<" "<<ans.sec<<endl; } } }

Compilation message (stderr)

naboj.cpp: In function 'void tes3()':
naboj.cpp:17:14: warning: unused variable 'temp3' [-Wunused-variable]
   17 |   int maxjar,temp3;
      |              ^~~~~
naboj.cpp: At global scope:
naboj.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...