結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2017-03-30 16:22:43 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 811 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 03:01:07 |
合計ジャッジ時間 | 997 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 WA * 6 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:13:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d %d",&l,&n); | ^~~~~~~~~~~~~~~~~~~~ main.c:17:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%d",&w[i]); | ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> #include <stdlib.h> #define INF 1000000000; void Qsort(int x[], int left, int right); void swap(int x[],int i,int j); int main(void){ int l,n; scanf("%d %d",&l,&n); int w[n]; int i; for(i=0;i<n;i++){ scanf("%d",&w[i]); } Qsort(w,0,n-1); int cnt=0; i=0; while(l-w[i]>=0){ cnt++; l=l-w[i]; i++; } printf("%d\n",cnt); return 0; } void Qsort(int x[], int left, int right){ int i,j; int pivot; i=left; j=right; pivot=x[(left+right)/2]; while(1){ while(x[i]<pivot) i++; while(pivot<x[j]) j--; if(i>=j) break; swap(x,i,j); i++; j--; } if(left<i-1) Qsort(x,left,i-1); if(j+1<right) Qsort(x,j+1,right); } void swap(int x[],int i,int j){ int temp; temp=x[i]; x[i]=x[j]; x[j]=temp; }