답안 #211711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211711 2020-03-21T04:38:57 Z goodboy Potatoes and fertilizers (LMIO19_bulves) C++14
0 / 100
19 ms 18048 KB
#include <stdio.h> 
#include <math.h>
using namespace std;

int fertiliser[1111111],potatoes[1111111];

int main() {
    int n , a , b;
    scanf("%d",&n);
	int pot = 0, fert = 0;
    for (int i = 1; i <= n; i++){
    	scanf("%d%d",&a,&b);
      	for (int j = 1; j <= a; j++){
          	fert++;
          	fertiliser[fert] = i;
		}
      	for (int j = 1; j <= b; j++){
          	pot++;
          	potatoes[pot] = i;
        }
  	}
  	long long ans = 0;
  	for(int i = 1; i <= pot; i++)ans += abs(fertiliser[i] - potatoes[i]);
  	printf("%lld\n",ans);
}

Compilation message

bulves.cpp: In function 'int main()':
bulves.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bulves.cpp:12:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d%d",&a,&b);
      ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Runtime error 19 ms 18048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Runtime error 19 ms 18048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Incorrect 5 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Runtime error 19 ms 18048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Runtime error 19 ms 18048 KB Execution killed with signal 11 (could be triggered by violating memory limits)