結果

問題 No.343 手抜き工事のプロ
ユーザー しらっ亭
提出日時 2016-02-12 23:10:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,246 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 158,560 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 04:52:27
合計ジャッジ時間 2,192 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |   scanf("%d", &N);
      |   ~~~~~^~~~~~~~~~
main.cpp:24:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |   scanf("%d", &L);
      |   ~~~~~^~~~~~~~~~
main.cpp:25:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |   REP(i, N-1) scanf("%d", X+i+1);
      |               ~~~~~^~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
typedef long long ll;
// -------------------------------------
int N, L;
int X[100101];
int R[100101];
int main() {
scanf("%d", &N);
scanf("%d", &L);
REP(i, N-1) scanf("%d", X+i+1);
R[0] = X[0] = 0;
/*
puts("----");
REP(i, N) {
_P("X[%d]=%d\n", i, X[i]);
}
*/
REP(i, N-1) {
int d = abs(X[i] - X[i+1]);
if (d >= L) {
puts("-1");
return 0;
}
R[i+1] = R[i] + X[i+1];
}
/*
REP(i, N) {
_P("R[%d]=%d\n", i, R[i]);
}
*/
int ans = 0;
FOR(i, 1, N) {
double j = 1.0 * (R[N-1] - R[i-1]) / (N-i);
//_P("j=%f\n", j);
if (abs(X[i-1] - j) * 2 >= L ||
abs(X[i] - j) * 2 >= L) ans++;
}
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0