답안 #833132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
833132 2023-08-22T01:59:21 Z josanneo22 Feast (NOI19_feast) C++17
4 / 100
25 ms 1492 KB
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define ar array

void solve(){
	int n,k; cin>>n>>k;
	vector<int> a(n); for(int i=0;i<n;i++) cin>>a[i];
	int pos=-1;
	for(int i=0;i<n;i++) if(a[i]<0) {pos=i;break;}
	if(pos==-1){ cout<<accumulate(a.begin(),a.end(),0LL)<<'\n';}
	else{cout<<accumulate(a.begin(),a.end(),0LL)-a[pos]<<'\n'; }
}
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	clock_t tStart = clock();
	int local=0,multi=0,debug=1,tt=1;
	if(local){
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	}	
	if(multi) cin>>tt;
	for(int i=1;i<=tt;i++){
		if(debug && multi && local) cout<<"样例 "<<i<<'\n';
		solve();
 	}
	fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
}

Compilation message

feast.cpp: In function 'int main()':
feast.cpp:25:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |      freopen("input.txt","r",stdin);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
feast.cpp:26:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |      freopen("output.txt","w",stdout);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1364 KB Output is correct
2 Correct 22 ms 1364 KB Output is correct
3 Correct 25 ms 1492 KB Output is correct
4 Correct 22 ms 1492 KB Output is correct
5 Correct 23 ms 1364 KB Output is correct
6 Correct 22 ms 1364 KB Output is correct
7 Correct 22 ms 1364 KB Output is correct
8 Correct 23 ms 1492 KB Output is correct
9 Correct 22 ms 1364 KB Output is correct
10 Correct 23 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 1364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1364 KB Output is correct
2 Correct 22 ms 1364 KB Output is correct
3 Correct 25 ms 1492 KB Output is correct
4 Correct 22 ms 1492 KB Output is correct
5 Correct 23 ms 1364 KB Output is correct
6 Correct 22 ms 1364 KB Output is correct
7 Correct 22 ms 1364 KB Output is correct
8 Correct 23 ms 1492 KB Output is correct
9 Correct 22 ms 1364 KB Output is correct
10 Correct 23 ms 1364 KB Output is correct
11 Incorrect 14 ms 1364 KB Output isn't correct
12 Halted 0 ms 0 KB -