답안 #781986

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781986 2023-07-13T14:32:21 Z kebine Naboj (COCI22_naboj) C++17
0 / 110
190 ms 23360 KB
#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

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(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Integer parameter [name=d] equals to 2, violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 190 ms 23360 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Integer parameter [name=d] equals to 2, violates the range [0, 1]
2 Halted 0 ms 0 KB -