Please sign in first.
Submission #32915917
Source Code Expand
#include <stdio.h>
int main() {
long long int n, x;
long long int a[200000];
long long int b[200000];
scanf("%lld %lld", &n, &x);
for (long long int i = 0; i < n; ++i) {
scanf("%lld %lld", &a[i], &b[i]);
}
long long int dp[200000];
dp[0] = a[0] + b[0];
for (int i = 1; i < n; ++i) {
dp[i] = dp[i-1] + a[i] + b[i];
}
long long int ans = 2000000000000000000;
for (int i = 0; i < n; ++i) {
long long int t = dp[i];
if (i+1 < x) {
t += (x-i-1) * b[i];
}
if (t < ans) {
ans = t;
}
}
printf("%lld\n", ans);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Trophy |
| User | Tsuyopon_1067 |
| Language | C (GCC 9.2.1) |
| Score | 400 |
| Code Size | 682 Byte |
| Status | AC |
| Exec Time | 55 ms |
| Memory | 6416 KiB |
Compile Error
./Main.c: In function ‘main’:
./Main.c:6:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
6 | scanf("%lld %lld", &n, &x);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
./Main.c:8:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
8 | scanf("%lld %lld", &a[i], &b[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 2 ms | 1692 KiB |
| example_01.txt | AC | 2 ms | 1640 KiB |
| test_00.txt | AC | 50 ms | 6312 KiB |
| test_01.txt | AC | 51 ms | 6336 KiB |
| test_02.txt | AC | 50 ms | 6316 KiB |
| test_03.txt | AC | 24 ms | 3672 KiB |
| test_04.txt | AC | 43 ms | 5356 KiB |
| test_05.txt | AC | 18 ms | 3076 KiB |
| test_06.txt | AC | 47 ms | 5996 KiB |
| test_07.txt | AC | 50 ms | 6364 KiB |
| test_08.txt | AC | 52 ms | 6312 KiB |
| test_09.txt | AC | 49 ms | 6404 KiB |
| test_10.txt | AC | 28 ms | 3796 KiB |
| test_11.txt | AC | 39 ms | 5048 KiB |
| test_12.txt | AC | 15 ms | 2624 KiB |
| test_13.txt | AC | 15 ms | 2704 KiB |
| test_14.txt | AC | 31 ms | 6392 KiB |
| test_15.txt | AC | 55 ms | 6416 KiB |
| test_16.txt | AC | 50 ms | 6364 KiB |
| test_17.txt | AC | 50 ms | 6320 KiB |
| test_18.txt | AC | 51 ms | 6336 KiB |