제출 #1111248

#제출 시각아이디문제언어결과실행 시간메모리
1111248StefanSebezRoom Temperature (JOI24_ho_t1)C++14
50 / 100
2 ms592 KiB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
const int inf=1e9;
int n,T;
int Dist(int x,int y){
	while(x<0)x+=T;x%=T;
	while(y<0)y+=T;y%=T;
	return min(abs(x-y),T-abs(x-y));
}
int main(){
    scanf("%i%i",&n,&T);
    int a[2*n+10];for(int i=1;i<=n;i++) scanf("%i",&a[i]),a[i]%=T;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++) a[i+n]=a[i];
    //for(int i=1;i<=n;i++) printf("%i ",a[i]);printf("\n");
    int res=inf;
    for(int i=1,j=2;i<=n;i++){
		while(j<2*n&&Dist(a[i],a[j])<=Dist(a[i],a[j+1]))j++;
		//printf("%i: %i\n",a[i],a[j]);
		res=min(res,(Dist(a[i],a[j])+1)/2);
    }
    printf("%i\n",res);
    return 0;
}

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

Main.cpp: In function 'int Dist(int, int)':
Main.cpp:11:2: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   11 |  while(x<0)x+=T;x%=T;
      |  ^~~~~
Main.cpp:11:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   11 |  while(x<0)x+=T;x%=T;
      |                 ^
Main.cpp:12:2: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   12 |  while(y<0)y+=T;y%=T;
      |  ^~~~~
Main.cpp:12:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   12 |  while(y<0)y+=T;y%=T;
      |                 ^
Main.cpp: In function 'int main()':
Main.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%i%i",&n,&T);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:17:46: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     int a[2*n+10];for(int i=1;i<=n;i++) scanf("%i",&a[i]),a[i]%=T;
      |                                         ~~~~~^~~~~~~~~~~~
#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...