結果
問題 | No.468 役に立つ競技プログラミング実践編 |
ユーザー | Yamyuki |
提出日時 | 2016-12-19 17:44:10 |
言語 | C90 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 265 ms / 2,000 ms |
コード長 | 1,583 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 25,948 KB |
実行使用メモリ | 20,828 KB |
最終ジャッジ日時 | 2023-08-21 01:19:15 |
合計ジャッジ時間 | 4,671 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,608 KB |
testcase_01 | AC | 2 ms
4,732 KB |
testcase_02 | AC | 2 ms
4,576 KB |
testcase_03 | AC | 2 ms
4,552 KB |
testcase_04 | AC | 1 ms
4,616 KB |
testcase_05 | AC | 1 ms
4,676 KB |
testcase_06 | AC | 2 ms
4,556 KB |
testcase_07 | AC | 2 ms
4,668 KB |
testcase_08 | AC | 2 ms
4,640 KB |
testcase_09 | AC | 2 ms
4,732 KB |
testcase_10 | AC | 1 ms
4,728 KB |
testcase_11 | AC | 2 ms
4,668 KB |
testcase_12 | AC | 2 ms
4,720 KB |
testcase_13 | AC | 2 ms
4,668 KB |
testcase_14 | AC | 3 ms
4,752 KB |
testcase_15 | AC | 3 ms
4,756 KB |
testcase_16 | AC | 3 ms
4,768 KB |
testcase_17 | AC | 4 ms
4,752 KB |
testcase_18 | AC | 3 ms
4,760 KB |
testcase_19 | AC | 4 ms
4,740 KB |
testcase_20 | AC | 3 ms
4,740 KB |
testcase_21 | AC | 3 ms
4,640 KB |
testcase_22 | AC | 3 ms
4,808 KB |
testcase_23 | AC | 3 ms
4,640 KB |
testcase_24 | AC | 260 ms
20,724 KB |
testcase_25 | AC | 265 ms
20,744 KB |
testcase_26 | AC | 259 ms
20,800 KB |
testcase_27 | AC | 259 ms
20,824 KB |
testcase_28 | AC | 257 ms
20,720 KB |
testcase_29 | AC | 263 ms
20,828 KB |
testcase_30 | AC | 265 ms
20,808 KB |
testcase_31 | AC | 261 ms
20,736 KB |
testcase_32 | AC | 261 ms
20,740 KB |
testcase_33 | AC | 263 ms
20,784 KB |
testcase_34 | AC | 52 ms
10,700 KB |
testcase_35 | AC | 2 ms
4,680 KB |
testcase_36 | AC | 2 ms
4,668 KB |
コンパイルメッセージ
main.c:13:6: warning: built-in function ‘index’ declared as non-function [-Wbuiltin-declaration-mismatch] long index[100000]; ^~~~~ main.c: In function ‘main’: main.c:64:2: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration] memset(limit,1,sizeof(limit)); ^~~~~~ main.c:64:2: warning: incompatible implicit declaration of built-in function ‘memset’ main.c:64:2: note: include ‘<string.h>’ or provide a declaration of ‘memset’ main.c:3:1: +#include <string.h> #define max(x,y) ((x)>(y)?(x):(y)) main.c:64:2: memset(limit,1,sizeof(limit)); ^~~~~~
ソースコード
#include<stdio.h> #include<stdlib.h> #define max(x,y) ((x)>(y)?(x):(y)) #define min(x,y) ((x)<(y)?(x):(y)) long n,m,work[100000]; typedef struct{ int cost; long f,e; } node; node pass[500000]; long index[100000]; long next[100000]; long time[100000]; long limit[100000]; int cmp_1(const void *a,const void*b){ return ((node*)a)->f-((node*)b)->f; } int cmp_2(const void*a,const void*b){ return ((node*)a)->e-((node*)b)->e; } int main(){ long i,j,count,cri; scanf("%ld %ld",&n,&m); for(i=0;i<m;i++){ scanf("%ld %ld %d",&pass[i].f,&pass[i].e,&pass[i].cost); work[pass[i].e]++; } qsort(pass,m,sizeof(node),cmp_1); j=0; for(i=0;i<m && j<n-1;i++){ if(pass[i].f!=j){ j++; index[j]=i; } } count=1; for(i=0;i<n;i++){ count--; for(j=index[next[i]];pass[j].f==next[i];j++){ time[pass[j].e]=max(time[pass[j].e],time[next[i]]+(long)pass[j].cost); work[pass[j].e]--; if(work[pass[j].e]==0){ count++; next[i+count]=pass[j].e; } } } printf("%ld ",time[n-1]); qsort(pass,m,sizeof(node),cmp_2); j=0; for(i=0;i<m;i++){ if(pass[i].e!=j){ j++; index[j]=i; } work[pass[i].f]++; } cri=1; next[0]=n-1; memset(limit,1,sizeof(limit)); limit[n-1]=time[n-1]; count=1; for(i=0;i<n;i++){ count--; for(j=index[next[i]];pass[j].e==next[i];j++){ limit[pass[j].f]=min(limit[pass[j].f],limit[next[i]]-(long)pass[j].cost); work[pass[j].f]--; if(work[pass[j].f]==0){ if(time[pass[j].f]==limit[pass[j].f]){ cri++; } count++; next[i+count]=pass[j].f; } } } printf("%ld/%ld\n",n-cri,n); return 0; }