結果
| 問題 |
No.139 交差点
|
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2015-01-30 00:13:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 533 bytes |
| コンパイル時間 | 191 ms |
| コンパイル使用メモリ | 35,072 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 04:19:10 |
| 合計ジャッジ時間 | 949 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | int n,l,x[101],w[101],t[101];scanf("%d%d",&n,&l);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d%d%d",&x[i],&w[i],&t[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
//namaega184
int main(){
int n,l,x[101],w[101],t[101];scanf("%d%d",&n,&l);
bool b[101];
for(int i=0;i<n;i++){
scanf("%d%d%d",&x[i],&w[i],&t[i]);
b[i]=1;
}
int ans=0,pos=0,tm=0;
for(int i=0;i<n;i++){
ans+=x[i]-pos;
pos=x[i];
if(ans/t[i]%2)ans+=w[i]+(t[i]-ans%t[i]);
else{
if((t[i]-ans%t[i])<w[i])ans+=w[i]+(t[i]-ans%t[i])+t[i];
else ans+=w[i];
}
pos+=w[i];
}
printf("%d\n",ans+l-pos);
return 0;
}
184