Submission #14811314


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int D,M;
int C[26];
int S[400][26];
int T[400];
int day[26];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>D;
	FOR(i,26) cin>>C[i];
	FOR(i,D) {
		FOR(j,26) cin>>S[i][j];
	}
	
	int sum=0;
	FOR(i,D) {
		cin>>T[i];
		T[i]--;
	}
	cin>>M;
	while(M--) {
		cin>>x>>y;
		T[x-1]=y-1;
		int sum=0;
		ZERO(day);
		
		FOR(i,D) {
			sum+=S[i][T[i]];
			day[T[i]]=i+1;
			FOR(j,26) sum-=C[j]*(i+1-day[j]);
		}
		cout<<sum<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task C - Incremental Scoring
User kmjp
Language C++ (GCC 9.2.1)
Score 1
Code Size 1159 Byte
Status AC
Exec Time 961 ms
Memory 3656 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:23:10: warning: unused variable ‘k’ [-Wunused-variable]
   23 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:23:12: warning: unused variable ‘l’ [-Wunused-variable]
   23 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp:23:14: warning: unused variable ‘r’ [-Wunused-variable]
   23 |  int i,j,k,l,r,x,y; string s;
      |              ^
./Main.cpp:31:6: warning: unused variable ‘sum’ [-Wunused-variable]
   31 |  int sum=0;
      |      ^~~
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:7:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    7 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:56:38: note: in expansion of macro ‘FOR’
   56 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

Judge Result

Set Name test_ALL
Score / Max Score 1 / 1
Status
AC × 5
Set Name Test Cases
test_ALL test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt
Case Name Status Exec Time Memory
test_00.txt AC 11 ms 3552 KB
test_01.txt AC 4 ms 3656 KB
test_02.txt AC 22 ms 3596 KB
test_03.txt AC 114 ms 3644 KB
test_04.txt AC 961 ms 3656 KB