Submission #2532041
Source Code Expand
#include <iostream> #include <cstdio> #include <algorithm> #include<iostream> #include <cstring> #define N 505 using namespace std; typedef long long ll; int c[505]; int s[505]; int f[505]; int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d%d%d",&c[i],&s[i],&f[i]); for(int i=1;i<=n;i++){ int ans=0; for(int j=i;j<n;j++){ if(ans<s[j]) ans=s[j]; if(ans%f[j]!=0) ans=ans+f[j]-ans%f[j]; ans+=c[j]; } printf("%d\n",ans); } } #include <iostream> #include <cstdio> #include <algorithm> #include<iostream> #include <cstring> #define N 505 using namespace std; typedef long long ll; int c[505]; int s[505]; int f[505]; int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d%d%d",&c[i],&s[i],&f[i]); for(int i=1;i<=n;i++){ int ans=0; for(int j=i;j<n;j++){ if(ans<s[j]) ans=s[j]; if(ans%f[j]!=0) ans=ans+f[j]-ans%f[j]; ans+=c[j]; } printf("%d\n",ans); } } Submission
Submission Info
Submission Time | |
---|---|
Task | C - Special Trains |
User | vjudge4 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1151 Byte |
Status | CE |
Compile Error
./Main.cpp:39:10: error: redefinition of ‘int c [505]’ int c[505]; ^ ./Main.cpp:9:5: note: ‘int c [505]’ previously declared here int c[505]; ^ ./Main.cpp:40:10: error: redefinition of ‘int s [505]’ int s[505]; ^ ./Main.cpp:10:5: note: ‘int s [505]’ previously declared here int s[505]; ^ ./Main.cpp:41:10: error: redefinition of ‘int f [505]’ int f[505]; ^ ./Main.cpp:11:5: note: ‘int f [505]’ previously declared here int f[505]; ^ ./Main.cpp: In function ‘int main()’: ./Main.cpp:42:5: error: redefinition of ‘int main()’ int main() ^ ./Main.cpp:12:5: note: ‘int main()’ previously defined here int main() ^ ./Main.cpp: At global scope: ./Main.cpp:61:1: error: ‘Submission’ does not name a type Submission ^ ./Main.cpp: In function ‘int main()’: ./Main.cpp:15:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:17:42: wa...