제출 #1110166

#제출 시각아이디문제언어결과실행 시간메모리
1110166lamlamjjdoFish 3 (JOI24_fish3)C++17
0 / 100
1298 ms4936 KiB
#include<bits/stdc++.h> using namespace std; int n,d; long long a[5000]; main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen("c.INP","r")){ freopen("c.INP","r",stdin); freopen("c.OUT","w",stdout); } cin >>n>>d; for(int i=1;i<=n;i++){ cin >>a[i]; } int q; cin >>q; while(q--){ int l,r; cin >>l>>r; long long lst=a[r]; long long c=0; bool t=true; for(int i=r-1;i>=l;i--){ if(a[i]>lst){ long long g=(a[i]-lst+d-1)/d; if(a[i]<g*d){ t=false; break; } lst=a[i]-g*d; c+=g; } else lst=a[i]; } if(t)cout <<c<<'\n'; else cout<<-1<<'\n'; } }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:5:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 |  main(){
      |  ^~~~
Main.cpp: In function 'int main()':
Main.cpp:10:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         freopen("c.INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen("c.OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...